diff --git a/tests/Precondition/Service/ActiveAndStagingDirsAreDifferentUnitTest.php b/tests/Precondition/Service/ActiveAndStagingDirsAreDifferentUnitTest.php index c2d2060bb..744b43ca9 100644 --- a/tests/Precondition/Service/ActiveAndStagingDirsAreDifferentUnitTest.php +++ b/tests/Precondition/Service/ActiveAndStagingDirsAreDifferentUnitTest.php @@ -5,7 +5,6 @@ use PhpTuf\ComposerStager\Internal\Precondition\Service\ActiveAndStagingDirsAreDifferent; use PhpTuf\ComposerStager\Tests\TestUtils\PathHelper; use PhpTuf\ComposerStager\Tests\Translation\Factory\TestTranslatableFactory; -use PhpTuf\ComposerStager\Tests\Translation\Value\TestTranslatableExceptionMessage; /** * @coversDefaultClass \PhpTuf\ComposerStager\Internal\Precondition\Service\ActiveAndStagingDirsAreDifferent @@ -39,11 +38,6 @@ public function testUnfulfilled(): void { $samePath = PathHelper::activeDirPath(); - $this->doTestUnfulfilled( - new TestTranslatableExceptionMessage('The active and staging directories are the same.'), - null, - $samePath, - $samePath, - ); + $this->doTestUnfulfilled('The active and staging directories are the same.', null, $samePath, $samePath); } } diff --git a/tests/Precondition/Service/ActiveDirExistsUnitTest.php b/tests/Precondition/Service/ActiveDirExistsUnitTest.php index ab0aa7961..4e32bde24 100644 --- a/tests/Precondition/Service/ActiveDirExistsUnitTest.php +++ b/tests/Precondition/Service/ActiveDirExistsUnitTest.php @@ -6,7 +6,6 @@ use PhpTuf\ComposerStager\Internal\Precondition\Service\ActiveDirExists; use PhpTuf\ComposerStager\Tests\TestUtils\PathHelper; use PhpTuf\ComposerStager\Tests\Translation\Factory\TestTranslatableFactory; -use PhpTuf\ComposerStager\Tests\Translation\Value\TestTranslatableExceptionMessage; use Prophecy\Prophecy\ObjectProphecy; /** @@ -55,6 +54,6 @@ public function testUnfulfilled(): void ->exists(PathHelper::activeDirPath()) ->willReturn(false); - $this->doTestUnfulfilled(new TestTranslatableExceptionMessage($message)); + $this->doTestUnfulfilled($message); } } diff --git a/tests/Precondition/Service/ActiveDirIsReadyUnitTest.php b/tests/Precondition/Service/ActiveDirIsReadyUnitTest.php index ef37a2819..65f0e4d3e 100644 --- a/tests/Precondition/Service/ActiveDirIsReadyUnitTest.php +++ b/tests/Precondition/Service/ActiveDirIsReadyUnitTest.php @@ -7,7 +7,6 @@ use PhpTuf\ComposerStager\Internal\Precondition\Service\ActiveDirIsReady; use PhpTuf\ComposerStager\Tests\TestUtils\PathHelper; use PhpTuf\ComposerStager\Tests\Translation\Factory\TestTranslatableFactory; -use PhpTuf\ComposerStager\Tests\Translation\Value\TestTranslatableExceptionMessage; use Prophecy\Prophecy\ObjectProphecy; /** @@ -72,6 +71,6 @@ public function testUnfulfilled(): void ->assertIsFulfilled($activeDirPath, $stagingDirPath, $this->exclusions) ->willThrow($previous); - $this->doTestUnfulfilled(new TestTranslatableExceptionMessage($message)); + $this->doTestUnfulfilled($message); } } diff --git a/tests/Precondition/Service/BeginnerPreconditionsUnitTest.php b/tests/Precondition/Service/BeginnerPreconditionsUnitTest.php index 60fcc3d33..aa3bfa552 100644 --- a/tests/Precondition/Service/BeginnerPreconditionsUnitTest.php +++ b/tests/Precondition/Service/BeginnerPreconditionsUnitTest.php @@ -8,7 +8,6 @@ use PhpTuf\ComposerStager\Internal\Precondition\Service\BeginnerPreconditions; use PhpTuf\ComposerStager\Tests\TestUtils\PathHelper; use PhpTuf\ComposerStager\Tests\Translation\Factory\TestTranslatableFactory; -use PhpTuf\ComposerStager\Tests\Translation\Value\TestTranslatableExceptionMessage; use Prophecy\Prophecy\ObjectProphecy; /** @@ -83,6 +82,6 @@ public function testUnfulfilled(): void ->assertIsFulfilled($activeDirPath, $stagingDirPath, $this->exclusions) ->willThrow($previous); - $this->doTestUnfulfilled(new TestTranslatableExceptionMessage($message)); + $this->doTestUnfulfilled($message); } } diff --git a/tests/Precondition/Service/CleanerPreconditionsUnitTest.php b/tests/Precondition/Service/CleanerPreconditionsUnitTest.php index 3f9bd83eb..53b15a7b1 100644 --- a/tests/Precondition/Service/CleanerPreconditionsUnitTest.php +++ b/tests/Precondition/Service/CleanerPreconditionsUnitTest.php @@ -7,7 +7,6 @@ use PhpTuf\ComposerStager\Internal\Precondition\Service\CleanerPreconditions; use PhpTuf\ComposerStager\Tests\TestUtils\PathHelper; use PhpTuf\ComposerStager\Tests\Translation\Factory\TestTranslatableFactory; -use PhpTuf\ComposerStager\Tests\Translation\Value\TestTranslatableExceptionMessage; use Prophecy\Prophecy\ObjectProphecy; /** @@ -73,6 +72,6 @@ public function testUnfulfilled(): void ->assertIsFulfilled($activeDirPath, $stagingDirPath, $this->exclusions) ->willThrow($previous); - $this->doTestUnfulfilled(new TestTranslatableExceptionMessage($message)); + $this->doTestUnfulfilled($message); } } diff --git a/tests/Precondition/Service/CommitterPreconditionsUnitTest.php b/tests/Precondition/Service/CommitterPreconditionsUnitTest.php index b6bc37365..9fd58f16f 100644 --- a/tests/Precondition/Service/CommitterPreconditionsUnitTest.php +++ b/tests/Precondition/Service/CommitterPreconditionsUnitTest.php @@ -8,7 +8,6 @@ use PhpTuf\ComposerStager\Internal\Precondition\Service\CommitterPreconditions; use PhpTuf\ComposerStager\Tests\TestUtils\PathHelper; use PhpTuf\ComposerStager\Tests\Translation\Factory\TestTranslatableFactory; -use PhpTuf\ComposerStager\Tests\Translation\Value\TestTranslatableExceptionMessage; use Prophecy\Prophecy\ObjectProphecy; /** @@ -83,6 +82,6 @@ public function testUnfulfilled(): void ->assertIsFulfilled($activeDirPath, $stagingDirPath, $this->exclusions) ->willThrow($previous); - $this->doTestUnfulfilled(new TestTranslatableExceptionMessage($message)); + $this->doTestUnfulfilled($message); } } diff --git a/tests/Precondition/Service/CommonPreconditionsUnitTest.php b/tests/Precondition/Service/CommonPreconditionsUnitTest.php index f6f6e2638..bb019ab9f 100644 --- a/tests/Precondition/Service/CommonPreconditionsUnitTest.php +++ b/tests/Precondition/Service/CommonPreconditionsUnitTest.php @@ -9,7 +9,6 @@ use PhpTuf\ComposerStager\Internal\Precondition\Service\CommonPreconditions; use PhpTuf\ComposerStager\Tests\TestUtils\PathHelper; use PhpTuf\ComposerStager\Tests\Translation\Factory\TestTranslatableFactory; -use PhpTuf\ComposerStager\Tests\Translation\Value\TestTranslatableExceptionMessage; use Prophecy\Prophecy\ObjectProphecy; /** @@ -99,6 +98,6 @@ public function testUnfulfilled(): void ->assertIsFulfilled($activeDirPath, $stagingDirPath, $this->exclusions) ->willThrow($previous); - $this->doTestUnfulfilled(new TestTranslatableExceptionMessage($message)); + $this->doTestUnfulfilled($message); } } diff --git a/tests/Precondition/Service/PreconditionTestCase.php b/tests/Precondition/Service/PreconditionTestCase.php index 025d9bd8c..0e8a0f94a 100644 --- a/tests/Precondition/Service/PreconditionTestCase.php +++ b/tests/Precondition/Service/PreconditionTestCase.php @@ -9,6 +9,7 @@ use PhpTuf\ComposerStager\Tests\Path\Value\TestPathList; use PhpTuf\ComposerStager\Tests\TestCase; use PhpTuf\ComposerStager\Tests\TestUtils\PathHelper; +use PhpTuf\ComposerStager\Tests\Translation\Value\TestTranslatableExceptionMessage; abstract class PreconditionTestCase extends TestCase { @@ -56,11 +57,15 @@ protected function doTestFulfilled( } protected function doTestUnfulfilled( - TranslatableInterface $expectedStatusMessage, + TranslatableInterface|string $expectedStatusMessage, ?string $previousException = null, ?PathInterface $activeDirPath = null, ?PathInterface $stagingDirPath = null, ): void { + if (is_string($expectedStatusMessage)) { + $expectedStatusMessage = new TestTranslatableExceptionMessage($expectedStatusMessage); + } + $activeDirPath ??= PathHelper::activeDirPath(); $stagingDirPath ??= PathHelper::stagingDirPath(); $sut = $this->createSut(); diff --git a/tests/Precondition/Service/StagingDirDoesNotExistUnitTest.php b/tests/Precondition/Service/StagingDirDoesNotExistUnitTest.php index c8fc41fad..27a90ac5e 100644 --- a/tests/Precondition/Service/StagingDirDoesNotExistUnitTest.php +++ b/tests/Precondition/Service/StagingDirDoesNotExistUnitTest.php @@ -6,7 +6,6 @@ use PhpTuf\ComposerStager\Internal\Precondition\Service\StagingDirDoesNotExist; use PhpTuf\ComposerStager\Tests\TestUtils\PathHelper; use PhpTuf\ComposerStager\Tests\Translation\Factory\TestTranslatableFactory; -use PhpTuf\ComposerStager\Tests\Translation\Value\TestTranslatableExceptionMessage; use Prophecy\Prophecy\ObjectProphecy; /** @@ -50,7 +49,7 @@ public function testFulfilled(): void /** @covers ::assertIsFulfilled */ public function testUnfulfilled(): void { - $message = new TestTranslatableExceptionMessage('The staging directory already exists.'); + $message = 'The staging directory already exists.'; $this->filesystem ->exists(PathHelper::stagingDirPath()) ->willReturn(true); diff --git a/tests/Precondition/Service/StagingDirExistsUnitTest.php b/tests/Precondition/Service/StagingDirExistsUnitTest.php index 792a3ef37..01e362782 100644 --- a/tests/Precondition/Service/StagingDirExistsUnitTest.php +++ b/tests/Precondition/Service/StagingDirExistsUnitTest.php @@ -6,7 +6,6 @@ use PhpTuf\ComposerStager\Internal\Precondition\Service\StagingDirExists; use PhpTuf\ComposerStager\Tests\TestUtils\PathHelper; use PhpTuf\ComposerStager\Tests\Translation\Factory\TestTranslatableFactory; -use PhpTuf\ComposerStager\Tests\Translation\Value\TestTranslatableExceptionMessage; use Prophecy\Prophecy\ObjectProphecy; /** @@ -50,7 +49,7 @@ public function testFulfilled(): void /** @covers ::assertIsFulfilled */ public function testUnfulfilled(): void { - $message = new TestTranslatableExceptionMessage('The staging directory does not exist.'); + $message = 'The staging directory does not exist.'; $this->filesystem ->exists(PathHelper::stagingDirPath()) ->willReturn(false); diff --git a/tests/Precondition/Service/StagingDirIsWritableUnitTest.php b/tests/Precondition/Service/StagingDirIsWritableUnitTest.php index 71cbc1911..0483b8e66 100644 --- a/tests/Precondition/Service/StagingDirIsWritableUnitTest.php +++ b/tests/Precondition/Service/StagingDirIsWritableUnitTest.php @@ -6,7 +6,6 @@ use PhpTuf\ComposerStager\Internal\Precondition\Service\StagingDirIsWritable; use PhpTuf\ComposerStager\Tests\TestUtils\PathHelper; use PhpTuf\ComposerStager\Tests\Translation\Factory\TestTranslatableFactory; -use PhpTuf\ComposerStager\Tests\Translation\Value\TestTranslatableExceptionMessage; use Prophecy\Prophecy\ObjectProphecy; /** @@ -51,7 +50,7 @@ public function testFulfilled(): void /** @covers ::assertIsFulfilled */ public function testUnfulfilled(): void { - $message = new TestTranslatableExceptionMessage('The staging directory is not writable.'); + $message = 'The staging directory is not writable.'; $this->filesystem ->isWritable(PathHelper::stagingDirPath()) ->willReturn(false);