Passed
Pull Request — master (#9)
by Pedro
11:21
created

testInvalidRouteDoesNotCrash()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 2
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
4
 * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
5
 * @license   http://framework.zend.com/license/new-bsd New BSD License
6
 */
7
8
namespace ApplicationTest\Controller;
9
10
use Application\Controller\IndexController;
11
use Laminas\Stdlib\ArrayUtils;
12
use Laminas\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;
13
14
class IndexControllerTest extends AbstractHttpControllerTestCase
15
{
16
    public function setUp()
17
    {
18
        // The module configuration should still be applicable for tests.
19
        // You can override configuration here with test case specific values,
20
        // such as sample view templates, path stacks, module_listener_options,
21
        // etc.
22
        $configOverrides = [];
23
24
        $this->setApplicationConfig(ArrayUtils::merge(
25
            include __DIR__ . '/../../../../config/application.config.php',
26
            $configOverrides
27
        ));
28
29
        parent::setUp();
30
    }
31
32
    public function testIndexActionCanBeAccessed()
33
    {
34
        $this->dispatch('/', 'GET');
35
        $this->assertResponseStatusCode(200);
36
        $this->assertModuleName('application');
37
        $this->assertControllerName(IndexController::class); // as specified in router's controller name alias
38
        $this->assertControllerClass('IndexController');
39
        $this->assertMatchedRouteName('home');
40
    }
41
42
    public function testIndexActionViewModelTemplateRenderedWithinLayout()
43
    {
44
        $this->dispatch('/', 'GET');
45
        $this->assertQuery('section#location');
46
    }
47
48
    public function testInvalidRouteDoesNotCrash()
49
    {
50
        $this->dispatch('/invalid/route', 'GET');
51
        $this->assertResponseStatusCode(404);
52
    }
53
}
54