Completed
Push — master ( f39c0d...d229d7 )
by Tomas Norre
21:25 queued 19:23
created

GolfCourseControllerTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 37
rs 10
1
<?php
2
namespace TNM\GolfCourses\Tests\Unit\Controller;
3
/***************************************************************
4
 *  Copyright notice
5
 *
6
 *  (c) 2016 Tomas Norre Mikkelsen <[email protected]>
7
 *  			
8
 *  All rights reserved
9
 *
10
 *  This script is part of the TYPO3 project. The TYPO3 project is
11
 *  free software; you can redistribute it and/or modify
12
 *  it under the terms of the GNU General Public License as published by
13
 *  the Free Software Foundation; either version 2 of the License, or
14
 *  (at your option) any later version.
15
 *
16
 *  The GNU General Public License can be found at
17
 *  http://www.gnu.org/copyleft/gpl.html.
18
 *
19
 *  This script is distributed in the hope that it will be useful,
20
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 *  GNU General Public License for more details.
23
 *
24
 *  This copyright notice MUST APPEAR in all copies of the script!
25
 ***************************************************************/
26
27
/**
28
 * Test case for class TNM\GolfCourses\Controller\GolfCourseController.
29
 *
30
 * @author Tomas Norre Mikkelsen <[email protected]>
31
 */
32
class GolfCourseControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
33
{
34
35
	/**
36
	 * @var \TNM\GolfCourses\Controller\GolfCourseController
37
	 */
38
	protected $subject = NULL;
39
40
	public function setUp()
41
	{
42
		$this->subject = $this->getMock('TNM\\GolfCourses\\Controller\\GolfCourseController', array('redirect', 'forward', 'addFlashMessage'), array(), '', FALSE);
43
	}
44
45
	public function tearDown()
46
	{
47
		unset($this->subject);
48
	}
49
50
	/**
51
	 * @test
52
	 */
53
	public function listActionFetchesAllGolfCoursesFromRepositoryAndAssignsThemToView()
54
	{
55
56
		$allGolfCourses = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage', array(), array(), '', FALSE);
57
58
		$golfCourseRepository = $this->getMock('TNM\\GolfCourses\\Domain\\Repository\\GolfCourseRepository', array('findAll'), array(), '', FALSE);
59
		$golfCourseRepository->expects($this->once())->method('findAll')->will($this->returnValue($allGolfCourses));
60
		$this->inject($this->subject, 'golfCourseRepository', $golfCourseRepository);
61
62
		$view = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\View\\ViewInterface');
63
		$view->expects($this->once())->method('assign')->with('golfCourses', $allGolfCourses);
64
		$this->inject($this->subject, 'view', $view);
65
66
		$this->subject->listAction();
67
	}
68
}
69