diff --git a/CHANGELOG.md b/CHANGELOG.md index 08c7c3c..e15b71c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). ### Deprecated ### Removed +- Stop using Prophecy (#676) ### Fixed - Avoid race condition on case-insensitive filesystems (#657) diff --git a/Tests/Unit/Controller/TeaControllerTest.php b/Tests/Unit/Controller/TeaControllerTest.php index 1331d9d..63ffd10 100644 --- a/Tests/Unit/Controller/TeaControllerTest.php +++ b/Tests/Unit/Controller/TeaControllerTest.php @@ -5,9 +5,6 @@ declare(strict_types=1); namespace TTN\Tea\Tests\Unit\Controller; use PHPUnit\Framework\MockObject\MockObject; -use Prophecy\PhpUnit\ProphecyTrait; -use Prophecy\Prophecy\ObjectProphecy; -use Prophecy\Prophecy\ProphecySubjectInterface; use TTN\Tea\Controller\TeaController; use TTN\Tea\Domain\Model\Product\Tea; use TTN\Tea\Domain\Repository\Product\TeaRepository; @@ -23,22 +20,20 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase; */ class TeaControllerTest extends UnitTestCase { - use ProphecyTrait; - /** * @var TeaController&MockObject&AccessibleObjectInterface */ private TeaController $subject; /** - * @var ObjectProphecy + * @var TemplateView&MockObject */ - private ObjectProphecy $viewProphecy; + private TemplateView $viewMock; /** - * @var ObjectProphecy + * @var TeaRepository&MockObject */ - private ObjectProphecy $teaRepositoryProphecy; + private TeaRepository $teaRepositoryMock; protected function setUp(): void { @@ -50,17 +45,14 @@ class TeaControllerTest extends UnitTestCase ['forward', 'redirect', 'redirectToUri', 'htmlResponse'] ); - $this->viewProphecy = $this->prophesize(TemplateView::class); - $view = $this->viewProphecy->reveal(); - $this->subject->_set('view', $view); + $this->viewMock = $this->createMock(TemplateView::class); + $this->subject->_set('view', $this->viewMock); - $this->teaRepositoryProphecy = $this->prophesize(TeaRepository::class); - /** @var TeaRepository&ProphecySubjectInterface $teaRepository */ - $teaRepository = $this->teaRepositoryProphecy->reveal(); - $this->subject->injectTeaRepository($teaRepository); + $this->teaRepositoryMock = $this->getMockBuilder(TeaRepository::class)->disableOriginalConstructor()->getMock(); + $this->subject->injectTeaRepository($this->teaRepositoryMock); - $response = $this->prophesize(HtmlResponse::class)->reveal(); - $this->subject->method('htmlResponse')->willReturn($response); + $responseMock = $this->createMock(HtmlResponse::class); + $this->subject->method('htmlResponse')->willReturn($responseMock); } /** @@ -76,10 +68,9 @@ class TeaControllerTest extends UnitTestCase */ public function indexActionAssignsAllTeaAsTeasToView(): void { - $teas = $this->prophesize(QueryResultInterface::class)->reveal(); - $this->teaRepositoryProphecy->findAll()->willReturn($teas); - $this->viewProphecy->assign('teas', $teas)->shouldBeCalled(); - $this->viewProphecy->render()->willReturn(''); + $teas = $this->createMock(QueryResultInterface::class); + $this->teaRepositoryMock->method('findAll')->willReturn($teas); + $this->viewMock->expects(self::once())->method('assign')->with('teas', $teas); self::assertInstanceOf( HtmlResponse::class, @@ -93,8 +84,7 @@ class TeaControllerTest extends UnitTestCase public function showActionAssignsPassedTeaAsTeaToView(): void { $tea = new Tea(); - $this->viewProphecy->assign('tea', $tea)->shouldBeCalled(); - $this->viewProphecy->render()->willReturn(''); + $this->viewMock->expects(self::once())->method('assign')->with('tea', $tea); self::assertInstanceOf( HtmlResponse::class, diff --git a/Tests/Unit/Domain/Repository/Product/TeaRepositoryTest.php b/Tests/Unit/Domain/Repository/Product/TeaRepositoryTest.php index 8d9650f..22cadbf 100644 --- a/Tests/Unit/Domain/Repository/Product/TeaRepositoryTest.php +++ b/Tests/Unit/Domain/Repository/Product/TeaRepositoryTest.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace TTN\Tea\Tests\Unit\Domain\Repository\Product; -use Prophecy\PhpUnit\ProphecyTrait; use TTN\Tea\Domain\Repository\Product\TeaRepository; use TYPO3\CMS\Extbase\Object\ObjectManagerInterface; use TYPO3\CMS\Extbase\Persistence\Repository; @@ -15,8 +14,6 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase; */ class TeaRepositoryTest extends UnitTestCase { - use ProphecyTrait; - private TeaRepository $subject; protected function setUp(): void @@ -24,7 +21,7 @@ class TeaRepositoryTest extends UnitTestCase parent::setUp(); if (\interface_exists(ObjectManagerInterface::class)) { - $objectManager = $this->prophesize(ObjectManagerInterface::class)->reveal(); + $objectManager = $this->createMock(ObjectManagerInterface::class); // @phpstan-ignore-next-line This line is 11LTS-specific, but we're running PHPStan on TYPO3 12. $this->subject = new TeaRepository($objectManager); } else { diff --git a/composer.json b/composer.json index a8931a2..728d189 100644 --- a/composer.json +++ b/composer.json @@ -39,10 +39,7 @@ "ergebnis/composer-normalize": "^2.28.3", "friendsofphp/php-cs-fixer": "^3.13.0", "helmich/typo3-typoscript-lint": "^3.0.0", - "jangregor/phpstan-prophecy": "^1.0.0", "php-coveralls/php-coveralls": "^2.5.3", - "phpspec/prophecy": "^1.15.0", - "phpspec/prophecy-phpunit": "2.0.1", "phpstan/extension-installer": "^1.2.0", "phpstan/phpstan": "^1.9.1", "phpstan/phpstan-phpunit": "^1.2.2",