PageControllerTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * ownCloud - maps
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Sander Brand <[email protected]>
9
 * @copyright Sander Brand 2014
10
 */
11
12
namespace OCA\Maps\Controller;
13
14
use \OCP\AppFramework\Http\TemplateResponse;
15
use \OCA\Maps\AppInfo\Application;
16
17
18
class PageControllerTest extends \PHPUnit_Framework_TestCase {
19
20
	private $container;
21
22
	public function setUp () {
23
		$app = new Application();
24
		$this->container = $app->getContainer();
25
	}
26
27
	public function testIndex () {
28
		// swap out request
29
		$this->container['Request'] = $this->getMockBuilder('\OCP\IRequest')
30
			->getMock();
31
		$this->container['UserId'] = 'john';
32
33
		$result = $this->container['PageController']->index();
34
35
		$this->assertEquals(array('user' => 'john', 'devices' => []), $result->getParams());
36
		$this->assertEquals('main', $result->getTemplateName());
37
		$this->assertTrue($result instanceof TemplateResponse);
0 ignored issues
show
Bug introduced by
The class OCP\AppFramework\Http\TemplateResponse does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
38
	}
39
40
}
41