2018-06-23 20:18:07 +02:00
|
|
|
<?php
|
2018-07-15 11:10:08 +02:00
|
|
|
namespace Codappix\TestingTalk\Tests\Unit\Controller;
|
2018-06-23 20:18:07 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 Daniel Siepmann <coding@daniel-siepmann.de>
|
|
|
|
*
|
|
|
|
* This program 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.
|
|
|
|
*
|
|
|
|
* This program 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
* 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
use Codappix\TestingTalk\Controller\FrontendUserController;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2020-01-17 16:03:05 +01:00
|
|
|
use Prophecy\Prophecy\ObjectProphecy;
|
2018-06-23 20:18:07 +02:00
|
|
|
use TYPO3\CMS\Extbase\Domain\Model\FrontendUser;
|
2018-06-23 20:27:12 +02:00
|
|
|
use TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository;
|
2018-06-23 20:18:07 +02:00
|
|
|
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
|
|
|
|
use TYPO3\CMS\Extbase\Reflection\ObjectAccess;
|
|
|
|
|
|
|
|
class FrontendUserControllerTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var FrontendUserController
|
|
|
|
*/
|
|
|
|
protected $subject;
|
|
|
|
|
2018-06-23 20:27:12 +02:00
|
|
|
/**
|
2020-01-17 16:03:05 +01:00
|
|
|
* @var ObjectProphecy
|
2018-06-23 20:27:12 +02:00
|
|
|
*/
|
2020-01-17 16:03:05 +01:00
|
|
|
protected $view;
|
2018-06-23 20:27:12 +02:00
|
|
|
|
2019-02-01 09:43:09 +01:00
|
|
|
public function setUp(): void
|
2018-06-23 20:18:07 +02:00
|
|
|
{
|
|
|
|
$this->subject = new FrontendUserController();
|
2020-01-17 16:03:05 +01:00
|
|
|
$this->view = $this->prophesize(ViewInterface::class);
|
|
|
|
ObjectAccess::setProperty($this->subject, 'view', $this->view->reveal(), true);
|
2018-06-23 20:18:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
2018-06-23 20:27:12 +02:00
|
|
|
public function providedFrontendUserIsAssignedToViewInShowAction()
|
2018-06-23 20:18:07 +02:00
|
|
|
{
|
2020-01-17 16:03:05 +01:00
|
|
|
$frontendUser = $this->prophesize(FrontendUser::class);
|
2018-06-23 20:18:07 +02:00
|
|
|
|
2020-01-17 16:03:05 +01:00
|
|
|
$this->view
|
|
|
|
->assign('frontendUser', $frontendUser->reveal())
|
|
|
|
->shouldBeCalled();
|
2018-06-23 20:18:07 +02:00
|
|
|
|
2020-01-17 16:03:05 +01:00
|
|
|
$this->subject->showAction($frontendUser->reveal());
|
2018-06-23 20:18:07 +02:00
|
|
|
}
|
2018-06-23 20:27:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function fetchedFrontendUsersAreAssignedToViewInIndexAction()
|
|
|
|
{
|
2020-01-17 16:03:05 +01:00
|
|
|
$frontendUserRepository = $this->prophesize(FrontendUserRepository::class);
|
|
|
|
ObjectAccess::setProperty($this->subject, 'frontendUserRepository', $frontendUserRepository->reveal(), true);
|
|
|
|
$frontendUserRepository
|
|
|
|
->findAll()
|
|
|
|
->willReturn(['user1' => 'test'])
|
|
|
|
->shouldBeCalled();
|
2018-06-23 20:27:12 +02:00
|
|
|
|
2020-01-17 16:03:05 +01:00
|
|
|
$this->view
|
|
|
|
->assign('frontendUsers', ['user1' => 'test'])
|
|
|
|
->shouldBeCalled();
|
2018-06-23 20:27:12 +02:00
|
|
|
|
|
|
|
$this->subject->indexAction();
|
|
|
|
}
|
2018-06-23 20:18:07 +02:00
|
|
|
}
|