From 111120265db6fdd7d70908aac16bd7405a4e44c1 Mon Sep 17 00:00:00 2001 From: Raphael Stolt Date: Tue, 23 Jul 2024 19:54:52 +0200 Subject: [PATCH] Utilises symfony/console constants --- tests/Commands/InitCommandTest.php | 11 +++--- tests/Commands/ValidateCommandTest.php | 53 +++++++++++++------------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/tests/Commands/InitCommandTest.php b/tests/Commands/InitCommandTest.php index 19fe0dc..ccdf7e2 100644 --- a/tests/Commands/InitCommandTest.php +++ b/tests/Commands/InitCommandTest.php @@ -15,6 +15,7 @@ use Stolt\LeanPackage\Tests\CommandTester; use Stolt\LeanPackage\Tests\TestCase; use Symfony\Component\Console\Application; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Output\OutputInterface; class InitCommandTest extends TestCase @@ -129,7 +130,7 @@ public function failingInitReturnsExpectedStatusCode(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() !== 0); + $this->assertTrue($commandTester->getStatusCode() !== Command::SUCCESS); $mock->disable(); } @@ -155,7 +156,7 @@ public function existingDefaultLpvFileIsNotOverwritten(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() !== 0); + $this->assertTrue($commandTester->getStatusCode() !== Command::SUCCESS); } #[Test] @@ -175,7 +176,7 @@ public function usingANonAvailablePresetShowsWarning(): void ); $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() !== 0); + $this->assertTrue($commandTester->getStatusCode() !== Command::SUCCESS); } #[Test] @@ -202,7 +203,7 @@ public function verboseOutputIsAvailableWhenDesired(): void ); $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() !== 0); + $this->assertTrue($commandTester->getStatusCode() !== Command::SUCCESS); } #[Test] @@ -218,7 +219,7 @@ public function existingDefaultLpvFileIsOverwrittenWhenDesired(): void $commandTester->execute([ 'command' => $command->getName(), 'directory' => WORKING_DIRECTORY, - '-o' => true, + '--overwrite' => true, ]); $expectedDisplay = <<assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -143,7 +144,7 @@ public function validateOnNonExistentGitattributesFilesSuggestsCreationWithAlign CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -184,7 +185,7 @@ public function showsDifferenceBetweenActualAndExpectedGitattributesContent(): v $this->assertContains($expectedDiffRow, $actualDisplayRows); } - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -253,7 +254,7 @@ public function filesInGlobalGitignoreAreExportIgnored(): void CONTENT; $this->assertStringEqualsStringIgnoringLineEndings($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -330,7 +331,7 @@ public function gitattributesFileWithNoExportIgnoresContentShowsExpectedContent( CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -409,7 +410,7 @@ public function licenseIsInSuggestedFileContentPerDefault(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -451,7 +452,7 @@ public function licenseIsNotInSuggestedFileContent(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -495,7 +496,7 @@ public function licenseIsNotInSuggestedFileContentWithCustomGlobPattern(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -546,7 +547,7 @@ public function presentExportIgnoredLicenseWithKeepLicenseOptionInvalidatesResul CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -592,7 +593,7 @@ public function archiveWithoutLicenseFileIsConsideredInvalid(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -674,7 +675,7 @@ public function failingGitattributesFilesCreationReturnsExpectedStatusCode(): vo CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); $mock->disable(); } @@ -897,7 +898,7 @@ public function invalidGitattributesReturnsExpectedStatusCode(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -944,7 +945,7 @@ public function optionalGlobPatternIsApplied(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -966,7 +967,7 @@ public function usageOfInvalidGlobFailsValidation(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -989,7 +990,7 @@ public function missingGlobPatternProducesUserFriendlyErrorMessage(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -1113,7 +1114,7 @@ public function nonLeanArchiveIsNotConsideredLeanPlural(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -1159,7 +1160,7 @@ public function nonLeanArchiveIsNotConsideredLeanSingular(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -1192,7 +1193,7 @@ public function impossibilityToResolveExpectedGitattributesFileContentIsInfoed() CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -1215,7 +1216,7 @@ public function invalidDirectoryAgumentReturnsExpectedStatusCode(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -1375,7 +1376,7 @@ public function staleExportIgnoresAreConsideredAsInvalid(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -1473,7 +1474,7 @@ public function failingGitattributesFilesOverwriteReturnsExpectedStatusCode(): v CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); $mock->disable(); } @@ -1569,7 +1570,7 @@ public function strictAlignmentOfExportIgnoresCanBeEnforced(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -1620,7 +1621,7 @@ public function strictAlignmentAndOrderOfExportIgnoresCanBeEnforced(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -1672,7 +1673,7 @@ public function strictOrderOfExportIgnoresCanBeEnforced(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -1872,7 +1873,7 @@ public function providedNonExistentGlobPatternFileFailsValidation(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test] @@ -1912,7 +1913,7 @@ public function providedInvalidGlobPatternFileFailsValidation(): void CONTENT; $this->assertSame($expectedDisplay, $commandTester->getDisplay()); - $this->assertTrue($commandTester->getStatusCode() > 0); + $this->assertTrue($commandTester->getStatusCode() > Command::SUCCESS); } #[Test]