Completed
Push — master ( baf9c0...cf2f5b )
by Wanderson
02:20
created

ControllerFactoryTest::testControllerIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 5
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 6
rs 9.4285
1
<?php
2
3
namespace Win\Mvc;
4
5
use Win\Mvc\Application;
6
use Win\Mvc\ControllerFactory;
7
use Win\Mvc\DefaultController;
8
9
class ControllerFactoryTest extends \PHPUnit_Framework_TestCase {
10
11
	public function testControllerNotFound() {
12
		new Application();
13
		$controller = ControllerFactory::create('this-controller-doent-exit');
14
		$notFound = $controller instanceof DefaultController || $controller instanceof Error404Controller;
0 ignored issues
show
Bug introduced by
The class Win\Mvc\Error404Controller 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...
15
		$this->assertTrue($notFound);
16
	}
17
18
	public function testControllerIndex() {
19
		new Application();
20
		$controller = ControllerFactory::create('index');
21
		$notFound = $controller instanceof DefaultController;
22
		$this->assertFalse($notFound);
23
	}
24
25
	public function testAutomaticActionName() {
26
		new Application();
27
		$controller = ControllerFactory::create('index', 'my-example-action');
28
		$this->assertEquals('myExampleAction', $controller->getAction());
29
	}
30
31
}
32