2019-07-18 13:44:19 +02:00
|
|
|
<?php
|
2021-01-07 08:50:43 +01:00
|
|
|
|
2019-07-18 13:44:19 +02:00
|
|
|
namespace Wrm\Events\Tests\Unit\Controller;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test case.
|
|
|
|
*
|
|
|
|
* @author Dirk Koritnik <koritnik@werkraum-media.de>
|
|
|
|
*/
|
|
|
|
class EventControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var \Wrm\Events\Controller\EventController
|
|
|
|
*/
|
|
|
|
protected $subject = null;
|
|
|
|
|
2021-01-07 09:01:58 +01:00
|
|
|
protected function setUp(): void
|
2019-07-18 13:44:19 +02:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
$this->subject = $this->getMockBuilder(\Wrm\Events\Controller\EventController::class)
|
|
|
|
->setMethods(['redirect', 'forward', 'addFlashMessage'])
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function listActionFetchesAllEventsFromRepositoryAndAssignsThemToView()
|
|
|
|
{
|
|
|
|
|
|
|
|
$allEvents = $this->getMockBuilder(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class)
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
|
2021-01-07 09:01:58 +01:00
|
|
|
// $eventRepository = $this->getMockBuilder(\::class)
|
|
|
|
// ->setMethods(['findAll'])
|
|
|
|
// ->disableOriginalConstructor()
|
|
|
|
// ->getMock();
|
2019-07-18 13:44:19 +02:00
|
|
|
$eventRepository->expects(self::once())->method('findAll')->will(self::returnValue($allEvents));
|
|
|
|
$this->inject($this->subject, 'eventRepository', $eventRepository);
|
|
|
|
|
|
|
|
$view = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface::class)->getMock();
|
|
|
|
$view->expects(self::once())->method('assign')->with('events', $allEvents);
|
|
|
|
$this->inject($this->subject, 'view', $view);
|
|
|
|
|
|
|
|
$this->subject->listAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function showActionAssignsTheGivenEventToView()
|
|
|
|
{
|
|
|
|
$event = new \Wrm\Events\Domain\Model\Event();
|
|
|
|
|
|
|
|
$view = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface::class)->getMock();
|
|
|
|
$this->inject($this->subject, 'view', $view);
|
|
|
|
$view->expects(self::once())->method('assign')->with('event', $event);
|
|
|
|
|
|
|
|
$this->subject->showAction($event);
|
|
|
|
}
|
|
|
|
}
|