mirror of
https://github.com/werkraum-media/events.git
synced 2024-12-23 20:46:10 +01:00
68 lines
2 KiB
PHP
68 lines
2 KiB
PHP
|
<?php
|
||
|
namespace Wrm\Events\Tests\Unit\Controller;
|
||
|
|
||
|
/**
|
||
|
* Test case.
|
||
|
*
|
||
|
* @author Dirk Koritnik <koritnik@werkraum-media.de>
|
||
|
*/
|
||
|
class EventsControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
|
||
|
{
|
||
|
/**
|
||
|
* @var \Wrm\Events\Controller\EventsController
|
||
|
*/
|
||
|
protected $subject = null;
|
||
|
|
||
|
protected function setUp()
|
||
|
{
|
||
|
parent::setUp();
|
||
|
$this->subject = $this->getMockBuilder(\Wrm\Events\Controller\EventsController::class)
|
||
|
->setMethods(['redirect', 'forward', 'addFlashMessage'])
|
||
|
->disableOriginalConstructor()
|
||
|
->getMock();
|
||
|
}
|
||
|
|
||
|
protected function tearDown()
|
||
|
{
|
||
|
parent::tearDown();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @test
|
||
|
*/
|
||
|
public function listActionFetchesAllEventssFromRepositoryAndAssignsThemToView()
|
||
|
{
|
||
|
|
||
|
$allEventss = $this->getMockBuilder(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class)
|
||
|
->disableOriginalConstructor()
|
||
|
->getMock();
|
||
|
|
||
|
$eventsRepository = $this->getMockBuilder(\::class)
|
||
|
->setMethods(['findAll'])
|
||
|
->disableOriginalConstructor()
|
||
|
->getMock();
|
||
|
$eventsRepository->expects(self::once())->method('findAll')->will(self::returnValue($allEventss));
|
||
|
$this->inject($this->subject, 'eventsRepository', $eventsRepository);
|
||
|
|
||
|
$view = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface::class)->getMock();
|
||
|
$view->expects(self::once())->method('assign')->with('eventss', $allEventss);
|
||
|
$this->inject($this->subject, 'view', $view);
|
||
|
|
||
|
$this->subject->listAction();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @test
|
||
|
*/
|
||
|
public function showActionAssignsTheGivenEventsToView()
|
||
|
{
|
||
|
$events = new \Wrm\Events\Domain\Model\Events();
|
||
|
|
||
|
$view = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface::class)->getMock();
|
||
|
$this->inject($this->subject, 'view', $view);
|
||
|
$view->expects(self::once())->method('assign')->with('events', $events);
|
||
|
|
||
|
$this->subject->showAction($events);
|
||
|
}
|
||
|
}
|