mirror of
https://github.com/FriendsOfTYPO3/tea.git
synced 2024-11-10 00:56:12 +01: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:
parent
0799bffc82
commit
14b8628483
4 changed files with 16 additions and 31 deletions
|
@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
- Stop using Prophecy (#676)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Avoid race condition on case-insensitive filesystems (#657)
|
- Avoid race condition on case-insensitive filesystems (#657)
|
||||||
|
|
|
@ -5,9 +5,6 @@ declare(strict_types=1);
|
||||||
namespace TTN\Tea\Tests\Unit\Controller;
|
namespace TTN\Tea\Tests\Unit\Controller;
|
||||||
|
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
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\Controller\TeaController;
|
||||||
use TTN\Tea\Domain\Model\Product\Tea;
|
use TTN\Tea\Domain\Model\Product\Tea;
|
||||||
use TTN\Tea\Domain\Repository\Product\TeaRepository;
|
use TTN\Tea\Domain\Repository\Product\TeaRepository;
|
||||||
|
@ -23,22 +20,20 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
|
||||||
*/
|
*/
|
||||||
class TeaControllerTest extends UnitTestCase
|
class TeaControllerTest extends UnitTestCase
|
||||||
{
|
{
|
||||||
use ProphecyTrait;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var TeaController&MockObject&AccessibleObjectInterface
|
* @var TeaController&MockObject&AccessibleObjectInterface
|
||||||
*/
|
*/
|
||||||
private TeaController $subject;
|
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
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
|
@ -50,17 +45,14 @@ class TeaControllerTest extends UnitTestCase
|
||||||
['forward', 'redirect', 'redirectToUri', 'htmlResponse']
|
['forward', 'redirect', 'redirectToUri', 'htmlResponse']
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->viewProphecy = $this->prophesize(TemplateView::class);
|
$this->viewMock = $this->createMock(TemplateView::class);
|
||||||
$view = $this->viewProphecy->reveal();
|
$this->subject->_set('view', $this->viewMock);
|
||||||
$this->subject->_set('view', $view);
|
|
||||||
|
|
||||||
$this->teaRepositoryProphecy = $this->prophesize(TeaRepository::class);
|
$this->teaRepositoryMock = $this->getMockBuilder(TeaRepository::class)->disableOriginalConstructor()->getMock();
|
||||||
/** @var TeaRepository&ProphecySubjectInterface $teaRepository */
|
$this->subject->injectTeaRepository($this->teaRepositoryMock);
|
||||||
$teaRepository = $this->teaRepositoryProphecy->reveal();
|
|
||||||
$this->subject->injectTeaRepository($teaRepository);
|
|
||||||
|
|
||||||
$response = $this->prophesize(HtmlResponse::class)->reveal();
|
$responseMock = $this->createMock(HtmlResponse::class);
|
||||||
$this->subject->method('htmlResponse')->willReturn($response);
|
$this->subject->method('htmlResponse')->willReturn($responseMock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,10 +68,9 @@ class TeaControllerTest extends UnitTestCase
|
||||||
*/
|
*/
|
||||||
public function indexActionAssignsAllTeaAsTeasToView(): void
|
public function indexActionAssignsAllTeaAsTeasToView(): void
|
||||||
{
|
{
|
||||||
$teas = $this->prophesize(QueryResultInterface::class)->reveal();
|
$teas = $this->createMock(QueryResultInterface::class);
|
||||||
$this->teaRepositoryProphecy->findAll()->willReturn($teas);
|
$this->teaRepositoryMock->method('findAll')->willReturn($teas);
|
||||||
$this->viewProphecy->assign('teas', $teas)->shouldBeCalled();
|
$this->viewMock->expects(self::once())->method('assign')->with('teas', $teas);
|
||||||
$this->viewProphecy->render()->willReturn('');
|
|
||||||
|
|
||||||
self::assertInstanceOf(
|
self::assertInstanceOf(
|
||||||
HtmlResponse::class,
|
HtmlResponse::class,
|
||||||
|
@ -93,8 +84,7 @@ class TeaControllerTest extends UnitTestCase
|
||||||
public function showActionAssignsPassedTeaAsTeaToView(): void
|
public function showActionAssignsPassedTeaAsTeaToView(): void
|
||||||
{
|
{
|
||||||
$tea = new Tea();
|
$tea = new Tea();
|
||||||
$this->viewProphecy->assign('tea', $tea)->shouldBeCalled();
|
$this->viewMock->expects(self::once())->method('assign')->with('tea', $tea);
|
||||||
$this->viewProphecy->render()->willReturn('');
|
|
||||||
|
|
||||||
self::assertInstanceOf(
|
self::assertInstanceOf(
|
||||||
HtmlResponse::class,
|
HtmlResponse::class,
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace TTN\Tea\Tests\Unit\Domain\Repository\Product;
|
namespace TTN\Tea\Tests\Unit\Domain\Repository\Product;
|
||||||
|
|
||||||
use Prophecy\PhpUnit\ProphecyTrait;
|
|
||||||
use TTN\Tea\Domain\Repository\Product\TeaRepository;
|
use TTN\Tea\Domain\Repository\Product\TeaRepository;
|
||||||
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
|
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
|
||||||
use TYPO3\CMS\Extbase\Persistence\Repository;
|
use TYPO3\CMS\Extbase\Persistence\Repository;
|
||||||
|
@ -15,8 +14,6 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
|
||||||
*/
|
*/
|
||||||
class TeaRepositoryTest extends UnitTestCase
|
class TeaRepositoryTest extends UnitTestCase
|
||||||
{
|
{
|
||||||
use ProphecyTrait;
|
|
||||||
|
|
||||||
private TeaRepository $subject;
|
private TeaRepository $subject;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
|
@ -24,7 +21,7 @@ class TeaRepositoryTest extends UnitTestCase
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
if (\interface_exists(ObjectManagerInterface::class)) {
|
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.
|
// @phpstan-ignore-next-line This line is 11LTS-specific, but we're running PHPStan on TYPO3 12.
|
||||||
$this->subject = new TeaRepository($objectManager);
|
$this->subject = new TeaRepository($objectManager);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -39,10 +39,7 @@
|
||||||
"ergebnis/composer-normalize": "^2.28.3",
|
"ergebnis/composer-normalize": "^2.28.3",
|
||||||
"friendsofphp/php-cs-fixer": "^3.13.0",
|
"friendsofphp/php-cs-fixer": "^3.13.0",
|
||||||
"helmich/typo3-typoscript-lint": "^3.0.0",
|
"helmich/typo3-typoscript-lint": "^3.0.0",
|
||||||
"jangregor/phpstan-prophecy": "^1.0.0",
|
|
||||||
"php-coveralls/php-coveralls": "^2.5.3",
|
"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/extension-installer": "^1.2.0",
|
||||||
"phpstan/phpstan": "^1.9.1",
|
"phpstan/phpstan": "^1.9.1",
|
||||||
"phpstan/phpstan-phpunit": "^1.2.2",
|
"phpstan/phpstan-phpunit": "^1.2.2",
|
||||||
|
|
Loading…
Reference in a new issue