events/Tests/Unit/Controller/EventControllerTest.php
Daniel Siepmann 59272afffd Add php code sniffer to follow PSR-12
Also apply ./vendor/bin/phpcbf to auto migrate what is possible.

Relates: #8092
2021-09-07 07:51:36 +02:00

68 lines
2 KiB
PHP

<?php
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;
protected function setUp()
{
parent::setUp();
$this->subject = $this->getMockBuilder(\Wrm\Events\Controller\EventController::class)
->setMethods(['redirect', 'forward', 'addFlashMessage'])
->disableOriginalConstructor()
->getMock();
}
protected function tearDown()
{
parent::tearDown();
}
/**
* @test
*/
public function listActionFetchesAllEventsFromRepositoryAndAssignsThemToView()
{
$allEvents = $this->getMockBuilder(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class)
->disableOriginalConstructor()
->getMock();
$eventRepository = $this->getMockBuilder(\::class)
->setMethods(['findAll'])
->disableOriginalConstructor()
->getMock();
$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);
}
}