Completed
Branch master (7af779)
by Julius
03:11 queued 55s
created

AppControllerTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 21
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 22
ccs 21
cts 21
cp 1
rs 9.2
cc 1
eloc 20
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016 Julius Härtl <[email protected]>
4
 *
5
 * @author Julius Härtl <[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\AppOrder\Tests\Unit\Controller;
25
26
use OCA\AppOrder\Util;
27
use OCP\AppFramework\Http;
28
use OCA\AppOrder\Controller\AppController;
29
use OCP\IConfig;
30
use OCP\IRequest;
31
use OCP\IURLGenerator;
32
33
class AppControllerTest extends \PHPUnit_Framework_TestCase {
34
35
	/** @var IRequest */
36
	private $request;
37
	/** @var IURLGenerator */
38
	private $urlGenerator;
39
	/** @var string */
40
	private $userId;
41
	/** @var string */
42
	private $appName;
43
	/** @var AppController */
44
	private $controller;
45
	/** @var IConfig */
46
	private $config;
47
	/** @var Util */
48
	private $util;
49
50 2
	public function setUp() {
51 2
		parent::setUp();
52 2
		$this->request = $this->getMockBuilder('OCP\IRequest')
53 2
			->disableOriginalConstructor()
54 2
			->getMock();
55 2
		$this->config = $this->getMockBuilder('OCP\IConfig')
56 2
			->disableOriginalConstructor()
57 2
			->getMock();
58 2
		$this->util = $this->getMockBuilder('\OCA\AppOrder\Util')
59 2
			->disableOriginalConstructor()
60 2
			->getMock();
61 2
		$this->urlGenerator = \OC::$server->getURLGenerator();
62 2
		$this->userId = 'admin';
63 2
		$this->appName = 'apporder';
64 2
		$this->controller = new AppController(
65 2
			$this->appName,
66 2
			$this->request,
67 2
			$this->urlGenerator,
68 2
			$this->util,
69 2
			$this->userId
70
		);
71 2
	}
72
73 1
	public function testIndex() {
74 1
		$this->util->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<OCA\AppOrder\Util>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
75 1
			->method('getAppOrder')
76 1
			->willReturn(json_encode(['/index.php/foo/bar', '/index.php/bar/foo']));
77 1
		$expected = new Http\RedirectResponse('/index.php/foo/bar');
78 1
		$result = $this->controller->index();
79 1
		$this->assertEquals($expected, $result);
80 1
	}
81
82 1
	public function testIndexEmpty() {
83 1
		$this->util->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<OCA\AppOrder\Util>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
84 1
			->method('getAppOrder')
85 1
			->willReturn("");
86 1
		$result = $this->controller->index();
87 1
		$expected = new Http\RedirectResponse('http://localhost/index.php/apps/files/');
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 80 characters; contains 82 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
88 1
		$this->assertEquals($expected, $result);
89 1
	}
90
91
92
}
93