mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-09-19 23:56:13 +02:00

[TASK] Stop using Prophecy (#676)

The Prophecy project is basically dead, and our Prophecy dependency
currently prevents installations on PHP 8.2 without having to resort
to fiddling with Composer's platform options.
This commit is contained in:
Oliver Klee 2022-11-05 17:08:32 +01:00 committed by GitHub
parent 0799bffc82
commit 14b8628483
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 31 deletions

View file

@ -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)

View file

@ -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<TemplateView>
* @var TemplateView&MockObject
*/
private ObjectProphecy $viewProphecy;
private TemplateView $viewMock;
/**
* @var ObjectProphecy<TeaRepository>
* @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,

View file

@ -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 {

View file

@ -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",