151 lines
5.4 KiB
PHP
151 lines
5.4 KiB
PHP
<?php
|
|
namespace HermannTelser\Zuladungsliste\Controller;
|
|
|
|
|
|
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
|
|
|
/***************************************************************
|
|
* Copyright notice
|
|
*
|
|
* (c) 2016 Hermann Telser <hermann.telser@gmail.com>, Hermann Telser
|
|
*
|
|
* All rights reserved
|
|
*
|
|
* This script is part of the TYPO3 project. The TYPO3 project is
|
|
* free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* The GNU General Public License can be found at
|
|
* http://www.gnu.org/copyleft/gpl.html.
|
|
*
|
|
* This script is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* This copyright notice MUST APPEAR in all copies of the script!
|
|
***************************************************************/
|
|
|
|
/**
|
|
* Test case for class HermannTelser\Zuladungsliste\Controller\KriterienController.
|
|
*
|
|
* @author Hermann Telser <hermann.telser@gmail.com>
|
|
*/
|
|
class ArchitektenController extends ActionController
|
|
{
|
|
|
|
/**
|
|
* @var \HermannTelser\Zuladungsliste\Controller\KriterienController
|
|
*/
|
|
protected $subject = NULL;
|
|
|
|
public function setUp()
|
|
{
|
|
$this->subject = $this->getMock('HermannTelser\Zuladungsliste\Controller\KriterienController', array('redirect', 'forward', 'addFlashMessage'), array(), '', FALSE);
|
|
}
|
|
|
|
public function tearDown()
|
|
{
|
|
unset($this->subject);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function listActionFetchesAllKriteriensFromRepositoryAndAssignsThemToView()
|
|
{
|
|
$allKriteriens = $this->getMock('TYPO3\CMS\Extbase\Persistence\ObjectStorage', array(), array(), '', FALSE);
|
|
$kriterienRepository = $this->getMock('HermannTelser\Zuladungsliste\Domain\Repository\KriterienRepository', array('findAll'), array(), '', FALSE);
|
|
$kriterienRepository->expects($this->once())->method('findAll')->will($this->returnValue($allKriteriens));
|
|
$this->inject($this->subject, 'kriterienRepository', $kriterienRepository);
|
|
$view = $this->getMock('TYPO3\CMS\Extbase\Mvc\View\ViewInterface');
|
|
$view->expects($this->once())->method('assign')->with('kriteriens', $allKriteriens);
|
|
$this->inject($this->subject, 'view', $view);
|
|
$this->subject->listAction();
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function showActionAssignsTheGivenKriterienToView()
|
|
{
|
|
$kriterien = new \HermannTelser\Zuladungsliste\Domain\Model\Kriterien();
|
|
$view = $this->getMock('TYPO3\CMS\Extbase\Mvc\View\ViewInterface');
|
|
$this->inject($this->subject, 'view', $view);
|
|
$view->expects($this->once())->method('assign')->with('kriterien', $kriterien);
|
|
$this->subject->showAction($kriterien);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function createActionAddsTheGivenKriterienToKriterienRepository()
|
|
{
|
|
$kriterien = new \HermannTelser\Zuladungsliste\Domain\Model\Kriterien();
|
|
$kriterienRepository = $this->getMock('HermannTelser\Zuladungsliste\Domain\Repository\KriterienRepository', array('add'), array(), '', FALSE);
|
|
$kriterienRepository->expects($this->once())->method('add')->with($kriterien);
|
|
$this->inject($this->subject, 'kriterienRepository', $kriterienRepository);
|
|
$this->subject->createAction($kriterien);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function editActionAssignsTheGivenKriterienToView()
|
|
{
|
|
$kriterien = new \HermannTelser\Zuladungsliste\Domain\Model\Kriterien();
|
|
$view = $this->getMock('TYPO3\CMS\Extbase\Mvc\View\ViewInterface');
|
|
$this->inject($this->subject, 'view', $view);
|
|
$view->expects($this->once())->method('assign')->with('kriterien', $kriterien);
|
|
$this->subject->editAction($kriterien);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function updateActionUpdatesTheGivenKriterienInKriterienRepository()
|
|
{
|
|
$kriterien = new \HermannTelser\Zuladungsliste\Domain\Model\Kriterien();
|
|
$kriterienRepository = $this->getMock('HermannTelser\Zuladungsliste\Domain\Repository\KriterienRepository', array('update'), array(), '', FALSE);
|
|
$kriterienRepository->expects($this->once())->method('update')->with($kriterien);
|
|
$this->inject($this->subject, 'kriterienRepository', $kriterienRepository);
|
|
$this->subject->updateAction($kriterien);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function deleteActionRemovesTheGivenKriterienFromKriterienRepository()
|
|
{
|
|
$kriterien = new \HermannTelser\Zuladungsliste\Domain\Model\Kriterien();
|
|
$kriterienRepository = $this->getMock('HermannTelser\Zuladungsliste\Domain\Repository\KriterienRepository', array('remove'), array(), '', FALSE);
|
|
$kriterienRepository->expects($this->once())->method('remove')->with($kriterien);
|
|
$this->inject($this->subject, 'kriterienRepository', $kriterienRepository);
|
|
$this->subject->deleteAction($kriterien);
|
|
}
|
|
|
|
/**
|
|
* action list
|
|
*
|
|
* @return void
|
|
*/
|
|
public function listAction()
|
|
{
|
|
// $architektens = $this->architektenRepository->findAll();
|
|
// $this->view->assign('architektens', $architektens);
|
|
}
|
|
|
|
/**
|
|
* action
|
|
*
|
|
* @return void
|
|
*/
|
|
public function Action()
|
|
{
|
|
|
|
}
|
|
|
|
}
|