MapperTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace KochTest\Mvc;
4
5
use Koch\Mvc\Mapper;
6
7
class MapperTest extends \PHPUnit_Framework_TestCase
8
{
9
    /**
10
     * @var Mapper
11
     */
12
    protected $object;
13
14
    /**
15
     * Sets up the fixture, for example, opens a network connection.
16
     * This method is called before a test is executed.
17
     */
18
    protected function setUp()
19
    {
20
        $this->object = new Mapper();
21
    }
22
23
    /**
24
     * Tears down the fixture, for example, closes a network connection.
25
     * This method is called after a test is executed.
26
     */
27
    protected function tearDown()
28
    {
29
        unset($this->object);
30
    }
31
32
    /**
33
     * @covers Koch\Mvc\Mapper::setApplicationNamespace
34
     * @covers Koch\Mvc\Mapper::getApplicationNamespace
35
     */
36
    public function testSetApplicationNamespace()
37
    {
38
        $this->object->setApplicationNamespace(__NAMESPACE__);
39
        $this->assertEquals('\KochTest\Mvc', Mapper::$applicationNamespace);
40
        $this->assertEquals('\KochTest\Mvc', $this->object->getApplicationNamespace());
41
    }
42
43
    /**
44
     * @covers Koch\Mvc\Mapper::getModulePath
45
     */
46
    public function testGetModulePath()
47
    {
48
        $this->assertEquals(APPLICATION_MODULES_PATH . 'ModuleABC/', $this->object->getModulePath('ModuleABC'));
49
    }
50
51
    /**
52
     * @covers Koch\Mvc\Mapper::mapControllerToFilename
53
     */
54
    public function testMapControllerToFilename()
55
    {
56
        $module_path = '/Modules/ModuleA';
0 ignored issues
show
Coding Style introduced by
$module_path does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
57
        $this->assertEquals(
58
            '/Modules/ModuleAController/Controller.php',
59
            $this->object->mapControllerToFilename($module_path)
0 ignored issues
show
Coding Style introduced by
$module_path does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
60
        );
61
62
        $module_path = '/Modules/ModuleB';
0 ignored issues
show
Coding Style introduced by
$module_path does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
63
        $controller  = 'Admin';
64
        $this->assertEquals(
65
            '/Modules/ModuleBController/AdminController.php',
66
            $this->object->mapControllerToFilename($module_path, $controller)
0 ignored issues
show
Coding Style introduced by
$module_path does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
67
        );
68
    }
69
70
    /**
71
     * @covers Koch\Mvc\Mapper::mapControllerToClassname
72
     */
73
    public function testMapControllerToClassname()
74
    {
75
        $this->object->setApplicationNamespace('Application');
76
77
        $module = 'SomeModuleA';
78
        $this->assertEquals(
79
            '\Application\Modules\SomeModuleA\Controller\SomeModuleAController',
80
            $this->object->mapControllerToClassname($module)
81
        );
82
83
        $module     = 'SomeModuleB';
84
        $controller = 'SomeControllerA';
85
        $this->assertEquals(
86
            '\Application\Modules\SomeModuleB\Controller\SomeControllerAController',
87
            $this->object->mapControllerToClassname($module, $controller)
88
        );
89
    }
90
91
    /**
92
     * @covers Koch\Mvc\Mapper::mapActionToMethodname
93
     */
94
    public function testMapActionToMethodname()
95
    {
96
        // default action
97
        $this->assertEquals('actionIndex', $this->object->mapActionToMethodname());
98
99
        // custom action
100
        $this->assertEquals('actionSomeActionName', $this->object->mapActionToMethodname('someActionName'));
101
    }
102
}
103