2018-05-26 20:46:55 +02:00
|
|
|
<?php
|
2019-12-07 12:13:32 +01:00
|
|
|
|
2019-08-12 17:25:59 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-12-01 12:16:06 +01:00
|
|
|
namespace TTN\Tea\Tests\Unit\Controller;
|
2018-05-26 20:46:55 +02:00
|
|
|
|
|
|
|
use Nimut\TestingFramework\TestCase\UnitTestCase;
|
2019-12-07 17:44:32 +01:00
|
|
|
use Prophecy\Prophecy\ObjectProphecy;
|
|
|
|
use Prophecy\Prophecy\ProphecySubjectInterface;
|
2019-12-01 12:16:06 +01:00
|
|
|
use TTN\Tea\Controller\TeaController;
|
|
|
|
use TTN\Tea\Domain\Model\Product\Tea;
|
|
|
|
use TTN\Tea\Domain\Repository\Product\TeaRepository;
|
2018-05-26 20:46:55 +02:00
|
|
|
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
|
|
|
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
|
|
|
|
use TYPO3\CMS\Fluid\View\TemplateView;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test case.
|
|
|
|
*/
|
|
|
|
class TeaControllerTest extends UnitTestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var TeaController
|
|
|
|
*/
|
|
|
|
private $subject = null;
|
|
|
|
|
|
|
|
/**
|
2021-09-15 02:09:37 +02:00
|
|
|
* @var ObjectProphecy
|
2018-05-26 20:46:55 +02:00
|
|
|
*/
|
|
|
|
private $viewProphecy = null;
|
|
|
|
|
|
|
|
/**
|
2021-09-15 02:09:37 +02:00
|
|
|
* @var ObjectProphecy
|
2018-05-26 20:46:55 +02:00
|
|
|
*/
|
|
|
|
private $teaRepositoryProphecy = null;
|
|
|
|
|
2019-08-12 17:25:59 +02:00
|
|
|
protected function setUp(): void
|
2018-05-26 20:46:55 +02:00
|
|
|
{
|
|
|
|
$this->subject = new TeaController();
|
|
|
|
|
|
|
|
$this->viewProphecy = $this->prophesize(TemplateView::class);
|
2019-08-12 17:43:02 +02:00
|
|
|
$view = $this->viewProphecy->reveal();
|
|
|
|
$this->inject($this->subject, 'view', $view);
|
2018-05-26 20:46:55 +02:00
|
|
|
|
|
|
|
$this->teaRepositoryProphecy = $this->prophesize(TeaRepository::class);
|
2021-09-15 02:09:37 +02:00
|
|
|
/** @var TeaRepository&ProphecySubjectInterface $teaRepository */
|
2019-08-12 17:43:02 +02:00
|
|
|
$teaRepository = $this->teaRepositoryProphecy->reveal();
|
|
|
|
$this->subject->injectTeaRepository($teaRepository);
|
2018-05-26 20:46:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
2019-08-12 17:25:59 +02:00
|
|
|
public function isActionController(): void
|
2018-05-26 20:46:55 +02:00
|
|
|
{
|
2019-08-12 17:25:59 +02:00
|
|
|
self::assertInstanceOf(ActionController::class, $this->subject);
|
2018-05-26 20:46:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
2019-08-12 17:25:59 +02:00
|
|
|
public function indexActionAssignsAllTeaAsTeasToView(): void
|
2018-05-26 20:46:55 +02:00
|
|
|
{
|
|
|
|
$teas = $this->prophesize(QueryResultInterface::class)->reveal();
|
|
|
|
$this->teaRepositoryProphecy->findAll()->willReturn($teas);
|
|
|
|
$this->viewProphecy->assign('teas', $teas)->shouldBeCalled();
|
|
|
|
|
|
|
|
$this->subject->indexAction();
|
|
|
|
}
|
2018-05-28 17:05:39 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
2019-08-12 17:25:59 +02:00
|
|
|
public function showActionAssignsPassedTeaAsTeaToView(): void
|
2018-05-28 17:05:39 +02:00
|
|
|
{
|
|
|
|
$tea = new Tea();
|
|
|
|
$this->viewProphecy->assign('tea', $tea)->shouldBeCalled();
|
|
|
|
|
|
|
|
$this->subject->showAction($tea);
|
|
|
|
}
|
2018-05-26 20:46:55 +02:00
|
|
|
}
|