Skip to content

Commit c3dc5e6

Browse files
Test shell exit code
1 parent d0cd8bf commit c3dc5e6

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tests/unit/TextUI/Command/Commands/VersionCheckCommandTest.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222
final class VersionCheckCommandTest extends TestCase
2323
{
2424
/**
25-
* @return non-empty-list<array{0: non-empty-string, 1: positive-int, 2: non-empty-string, 3: non-empty-string, 4: non-empty-string}>
25+
* @return non-empty-list<array{0: non-empty-string, 1: non-negative-int, 2: positive-int, 3: non-empty-string, 4: non-empty-string, 5: non-empty-string}>
2626
*/
2727
public static function provider(): array
2828
{
2929
return [
3030
[
3131
'You are using the latest version of PHPUnit.',
32+
Result::SUCCESS,
3233
10,
3334
'10.5.0',
3435
'10.5.0',
@@ -38,6 +39,7 @@ public static function provider(): array
3839
'You are not using the latest version of PHPUnit.
3940
The latest version compatible with PHPUnit 10.5.0 is PHPUnit 10.5.1.
4041
The latest version is PHPUnit 10.5.1.',
42+
Result::FAILURE,
4143
10,
4244
'10.5.0',
4345
'10.5.1',
@@ -47,6 +49,7 @@ public static function provider(): array
4749
'You are not using the latest version of PHPUnit.
4850
The latest version compatible with PHPUnit 10.5.0 is PHPUnit 10.5.1.
4951
The latest version is PHPUnit 11.0.0.',
52+
Result::FAILURE,
5053
10,
5154
'10.5.0',
5255
'11.0.0',
@@ -56,14 +59,15 @@ public static function provider(): array
5659
}
5760

5861
/**
59-
* @param non-empty-string $expected
62+
* @param non-empty-string $expectedMessage
63+
* @param non-negative-int $expectedShellExitCode
6064
* @param positive-int $majorVersionNumber
6165
* @param non-empty-string $versionId
6266
* @param non-empty-string $latestVersion
6367
* @param non-empty-string $latestCompatibleVersion
6468
*/
6569
#[DataProvider('provider')]
66-
public function testChecksVersion(string $expected, int $majorVersionNumber, string $versionId, string $latestVersion, string $latestCompatibleVersion): void
70+
public function testChecksVersion(string $expectedMessage, int $expectedShellExitCode, int $majorVersionNumber, string $versionId, string $latestVersion, string $latestCompatibleVersion): void
6771
{
6872
$command = new VersionCheckCommand(
6973
$this->downloader($latestVersion, $latestCompatibleVersion),
@@ -73,7 +77,8 @@ public function testChecksVersion(string $expected, int $majorVersionNumber, str
7377

7478
$result = $command->execute();
7579

76-
$this->assertSame($expected, trim($result->output()));
80+
$this->assertSame($expectedMessage, trim($result->output()));
81+
$this->assertSame($expectedShellExitCode, $result->shellExitCode());
7782
}
7883

7984
private function downloader(string $latestVersion, string $latestCompatibleVersion): Downloader&Stub

0 commit comments

Comments
 (0)