Skip to content

Commit 719371e

Browse files
authored
Merge pull request #25 from facile-it/phpunit-10
PHPUnit 10+, Psalm 6
2 parents 57b2d62 + b80e8d0 commit 719371e

File tree

10 files changed

+89
-76
lines changed

10 files changed

+89
-76
lines changed

.github/workflows/tests.yaml renamed to .github/workflows/ci.yaml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Tests
1+
name: CI
22

33
on:
44
pull_request: null
@@ -10,7 +10,7 @@ on:
1010

1111
jobs:
1212
Tests:
13-
name: PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}${{ matrix.dependencies }}
13+
name: PHP ${{ matrix.php }} Symfony ${{ matrix.symfony }}${{ matrix.description }}
1414
runs-on: ubuntu-latest
1515
env:
1616
SYMFONY_DEPRECATIONS_HELPER: 'max[self]=0'
@@ -26,8 +26,7 @@ jobs:
2626
php: '8.3'
2727
- symfony: '^6.4'
2828
php: '8.2'
29-
- description: 'Prefer lowest'
30-
php: '8.2'
29+
- php: '8.2'
3130
dependencies: '--prefer-lowest'
3231
env:
3332
SYMFONY_DEPRECATIONS_HELPER: 'disabled'
@@ -57,3 +56,30 @@ jobs:
5756
files: './coverage.xml'
5857
fail_ci_if_error: true
5958
token: ${{ secrets.CODECOV_TOKEN }}
59+
SA:
60+
strategy:
61+
matrix:
62+
include:
63+
- description: Validate composer.json
64+
script: composer validate
65+
- description: Code style
66+
script: vendor/bin/php-cs-fixer fix --ansi --verbose --dry-run
67+
- description: Rector
68+
script: vendor/bin/rector --ansi --dry-run
69+
- description: PHPStan
70+
script: vendor/bin/phpstan analyze
71+
- description: Psalm
72+
script: vendor/bin/psalm
73+
74+
name: ${{ matrix.description }}
75+
runs-on: ubuntu-latest
76+
steps:
77+
- name: Checkout
78+
uses: actions/checkout@v4
79+
- name: Setup PHP
80+
uses: shivammathur/setup-php@v2
81+
with:
82+
php-version: 8.2
83+
- name: Install dependencies
84+
uses: "ramsey/composer-install@v3"
85+
- run: ${{ matrix.script }}

.github/workflows/static-analysis.yaml

Lines changed: 0 additions & 36 deletions
This file was deleted.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ phpstan:
1313
vendor/bin/phpstan analyse
1414

1515
tests:
16-
vendor/bin/phpunit --verbose
16+
vendor/bin/phpunit
1717

1818
.PHONY: tests

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@
3636
"require-dev": {
3737
"facile-it/facile-coding-standard": "^1.2",
3838
"jangregor/phpstan-prophecy": "2.2.0",
39+
"phpspec/prophecy-phpunit": "^2.0",
3940
"phpstan/extension-installer": "^1.4",
4041
"phpstan/phpstan": "2.1.17",
4142
"phpstan/phpstan-phpunit": "2.0.6",
42-
"phpunit/phpunit": "^9.6.6",
43-
"phpspec/prophecy-phpunit": "^2.0",
43+
"phpunit/phpunit": "^10 || ^11 || ^12",
44+
"rector/rector": "2.0.17",
4445
"symfony/phpunit-bridge": "^6.4 || ^7.0",
45-
"vimeo/psalm": "^4.6 || ^5.0"
46+
"vimeo/psalm": "^6"
4647
}
4748
}

phpunit.xml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
4-
bootstrap="vendor/autoload.php"
5-
executionOrder="depends,defects"
6-
cacheResult="false"
7-
colors="true"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
executionOrder="depends,defects"
6+
cacheResult="false"
7+
colors="true"
88
beStrictAboutOutputDuringTests="true"
9-
beStrictAboutTodoAnnotatedTests="true"
10-
verbose="true">
9+
displayDetailsOnPhpunitDeprecations="true"
10+
displayDetailsOnTestsThatTriggerDeprecations="true"
11+
cacheDirectory=".phpunit.cache">
1112
<testsuites>
1213
<testsuite name="default">
1314
<directory suffix="Test.php">tests</directory>
1415
</testsuite>
1516
</testsuites>
16-
17-
<coverage processUncoveredFiles="true">
17+
<source>
1818
<include>
1919
<directory suffix=".php">src</directory>
2020
</include>
21-
</coverage>
21+
</source>
2222
</phpunit>

psalm-baseline.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<files psalm-version="6.12.0@cf420941d061a57050b6c468ef2c778faf40aee2">
3+
<file src="src/AbstractTerminableCommand.php">
4+
<UnusedClass>
5+
<code><![CDATA[AbstractTerminableCommand]]></code>
6+
</UnusedClass>
7+
</file>
8+
</files>

psalm.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
66
xmlns="https://getpsalm.org/schema/config"
77
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
errorBaseline="psalm-baseline.xml"
89
>
910
<projectFiles>
1011
<directory name="src" />
1112
<ignoreFiles>
1213
<directory name="vendor" />
1314
</ignoreFiles>
1415
</projectFiles>
16+
<issueHandlers>
17+
<MissingOverrideAttribute errorLevel="suppress" />
18+
</issueHandlers>
1519
</psalm>

rector.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
7+
return RectorConfig::configure()
8+
->withPaths([
9+
__DIR__ . '/src',
10+
__DIR__ . '/tests',
11+
])
12+
// uncomment to reach your current PHP version
13+
// ->withPhpSets()
14+
->withTypeCoverageLevel(0)
15+
->withDeadCodeLevel(0)
16+
->withCodeQualityLevel(0)
17+
->withAttributesSets(phpunit: true)
18+
->withSets([
19+
\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_100,
20+
])
21+
;

tests/E2E/TerminateCommandTest.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ class TerminateCommandTest extends TestCase
1717
private const STUB_COMMAND = 'stub:terminable:sleep';
1818

1919
/**
20-
* @dataProvider commandLineProvider
21-
*
2220
* @param string[] $commandLine
2321
*/
22+
#[\PHPUnit\Framework\Attributes\DataProvider('commandLineProvider')]
2423
public function testStubCommand(array $commandLine): void
2524
{
2625
$process = new Process($commandLine);
@@ -37,7 +36,7 @@ public function testStubCommand(array $commandLine): void
3736
/**
3837
* @return string[][][]
3938
*/
40-
public function commandLineProvider(): array
39+
public static function commandLineProvider(): array
4140
{
4241
return [
4342
[
@@ -58,9 +57,7 @@ public function commandLineProvider(): array
5857
];
5958
}
6059

61-
/**
62-
* @dataProvider provideSignals
63-
*/
60+
#[\PHPUnit\Framework\Attributes\DataProvider('provideSignals')]
6461
public function testSignalsDuringCommandBody(int $signal, int $exitCode): void
6562
{
6663
$process = new Process([
@@ -87,9 +84,7 @@ public function testSignalsDuringCommandBody(int $signal, int $exitCode): void
8784
$this->assertSame($exitCode, $process->getExitCode());
8885
}
8986

90-
/**
91-
* @dataProvider provideSignals
92-
*/
87+
#[\PHPUnit\Framework\Attributes\DataProvider('provideSignals')]
9388
public function testSigTermDuringSleep(int $signal, int $exitCode): void
9489
{
9590
$process = new Process([
@@ -119,7 +114,7 @@ public function testSigTermDuringSleep(int $signal, int $exitCode): void
119114
/**
120115
* @return array<array{int,int}>
121116
*/
122-
public function provideSignals(): array
117+
public static function provideSignals(): array
123118
{
124119
return [
125120
[SIGTERM, 143],

tests/Unit/AbstractTerminableCommandTest.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ protected function commandBody(InputInterface $input, OutputInterface $output):
7878
$stubCommand->run(new ArrayInput([]), $output->reveal());
7979
}
8080

81-
/**
82-
* @dataProvider signalProvider
83-
*/
81+
#[\PHPUnit\Framework\Attributes\DataProvider('signalProvider')]
8482
public function testReceiveSignalDuringCommandBody(int $signal): void
8583
{
8684
$stubCommand = new class ($signal) extends AbstractTerminableCommand {
@@ -112,17 +110,15 @@ protected function commandBody(InputInterface $input, OutputInterface $output):
112110
$this->assertSame(143, $exitCode);
113111
}
114112

115-
/**
116-
* @dataProvider signalProvider
117-
*/
113+
#[\PHPUnit\Framework\Attributes\DataProvider('signalProvider')]
118114
public function testReceiveSignalBeforeCommandBody(int $signal): void
119115
{
120116
$stubCommand = $this->createStubTerminableCommand();
121117

122118
$output = $this->prophesize(OutputInterface::class);
123119
$output->writeln(Argument::containingString('Starting'), OutputInterface::VERBOSITY_VERBOSE)
124120
->shouldBeCalledTimes(1)
125-
->will(function () use ($stubCommand, $signal) {
121+
->will(function () use ($stubCommand, $signal): void {
126122
$stubCommand->handleSignal($signal);
127123
});
128124
$output->writeln('Signal received, skipping execution', OutputInterface::VERBOSITY_NORMAL)
@@ -133,9 +129,7 @@ public function testReceiveSignalBeforeCommandBody(int $signal): void
133129
$this->assertSame(143, $exitCode);
134130
}
135131

136-
/**
137-
* @dataProvider signalProvider
138-
*/
132+
#[\PHPUnit\Framework\Attributes\DataProvider('signalProvider')]
139133
public function testGetSubscribedSignals(int $signal): void
140134
{
141135
$stubCommand = $this->createStubTerminableCommand();
@@ -146,7 +140,7 @@ public function testGetSubscribedSignals(int $signal): void
146140
/**
147141
* @return array{0: int}[]
148142
*/
149-
public function signalProvider(): array
143+
public static function signalProvider(): array
150144
{
151145
return [
152146
[SIGINT],

0 commit comments

Comments
 (0)