Passed
Push — master ( d6af32...4a464e )
by René
02:23
created

PageControllerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
dl 0
loc 74
rs 10
c 2
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 61 1
A testIndex() 0 5 1
1
<?php
2
/**
3
 * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <[email protected]>
4
 *
5
 * @author Kai Schröer <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 *  This program is free software: you can redistribute it and/or modify
10
 *  it under the terms of the GNU Affero General Public License as
11
 *  published by the Free Software Foundation, either version 3 of the
12
 *  License, or (at your option) any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU Affero General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU Affero General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
namespace OCA\Polls\Tests\Unit\Controller;
25
26
use OCA\Polls\Controller\PageController;
27
use OCP\AppFramework\Http\TemplateResponse;
0 ignored issues
show
Bug introduced by
The type OCP\AppFramework\Http\TemplateResponse was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
28
use PHPUnit_Framework_TestCase;
29
30
class PageControllerTest extends PHPUnit_Framework_TestCase {
31
32
	private $controller;
33
	private $userId = 'john';
34
35
	public function setUp() {
36
		$request = $this->getMockBuilder('OCP\IRequest')
37
			->disableOriginalConstructor()
38
			->getMock();
39
		$userManager = $this->getMockBuilder('OCP\IUserManager')
40
			->disableOriginalConstructor()
41
			->getMock();
42
		$groupManager = $this->getMockBuilder('OCP\IGroupManager')
43
			->disableOriginalConstructor()
44
			->getMock();
45
		$avatarManager = $this->getMockBuilder('OCP\IAvatarManager')
46
			->disableOriginalConstructor()
47
			->getMock();
48
		$logger = $this->getMockBuilder('OCP\ILogger')
49
			->disableOriginalConstructor()
50
			->getMock();
51
		$l10n = $this->getMockBuilder('OCP\IL10N')
52
			->disableOriginalConstructor()
53
			->getMock();
54
		$urlGenerator = $this->getMockBuilder('OCP\IURLGenerator')
55
			->disableOriginalConstructor()
56
			->getMock();
57
		$commentMapper = $this->getMockBuilder('OCA\Polls\Db\CommentMapper')
58
			->disableOriginalConstructor()
59
			->getMock();
60
		$dateMapper = $this->getMockBuilder('OCA\Polls\Db\DateMapper')
61
			->disableOriginalConstructor()
62
			->getMock();
63
		$eventMapper = $this->getMockBuilder('OCA\Polls\Db\EventMapper')
64
			->disableOriginalConstructor()
65
			->getMock();
66
		$notificationMapper = $this->getMockBuilder('OCA\Polls\Db\NotificationMapper')
67
			->disableOriginalConstructor()
68
			->getMock();
69
		$participationMapper = $this->getMockBuilder('OCA\Polls\Db\ParticipationMapper')
70
			->disableOriginalConstructor()
71
			->getMock();
72
		$participationTextMapper = $this->getMockBuilder('OCA\Polls\Db\ParticipationTextMapper')
73
			->disableOriginalConstructor()
74
			->getMock();
75
		$textMapper = $this->getMockBuilder('OCA\Polls\Db\TextMapper')
76
			->disableOriginalConstructor()
77
			->getMock();
78
79
		$this->controller = new PageController(
80
			'polls',
81
			$request,
82
			$userManager,
83
			$groupManager,
84
			$avatarManager,
85
			$logger,
86
			$l10n,
87
			$urlGenerator,
88
			$this->userId,
89
			$commentMapper,
90
			$dateMapper,
91
			$eventMapper,
92
			$notificationMapper,
93
			$participationMapper,
94
			$participationTextMapper,
95
			$textMapper
96
		);
97
	}
98
99
	public function testIndex() {
100
		$result = $this->controller->index();
101
102
		$this->assertEquals('main.tmpl', $result->getTemplateName());
103
		$this->assertTrue($result instanceof TemplateResponse);
104
	}
105
}
106