RuleTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 64
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testIfRuleCanBeMatched() 0 21 1
A testIfUrlCanBeGenerated() 0 12 1
A testTranslateToUrlEncodedPath() 0 13 1
1
<?php
2
/**
3
 * phpDocumentor
4
 *
5
 * PHP Version 5.3
6
 *
7
 * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
8
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
9
 * @link      http://phpdoc.org
10
 */
11
12
namespace phpDocumentor\Transformer\Router;
13
14
class RuleTest extends \Mockery\Adapter\Phpunit\MockeryTestCase
15
{
16
    /**
17
     * @covers phpDocumentor\Transformer\Router\Rule::__construct
18
     * @covers phpDocumentor\Transformer\Router\Rule::match
19
     */
20
    public function testIfRuleCanBeMatched()
21
    {
22
        $fixture = new Rule(
23
            function () {
24
                return true;
25
            },
26
            function () {
27
            }
28
        );
29
        $fixture2 = new Rule(
30
            function () {
31
                return false;
32
            },
33
            function () {
34
            }
35
        );
36
37
        $node = 'test';
38
        $this->assertTrue($fixture->match($node));
39
        $this->assertFalse($fixture2->match($node));
40
    }
41
42
    /**
43
     * @covers phpDocumentor\Transformer\Router\Rule::__construct
44
     * @covers phpDocumentor\Transformer\Router\Rule::generate
45
     */
46
    public function testIfUrlCanBeGenerated()
47
    {
48
        $fixture = new Rule(
49
            function () {
50
            },
51
            function () {
52
                return 'url';
53
            }
54
        );
55
56
        $this->assertSame('url', $fixture->generate('test'));
57
    }
58
59
    /**
60
     * @covers phpDocumentor\Transformer\Router\Rule::__construct
61
     * @covers phpDocumentor\Transformer\Router\Rule::generate
62
     * @covers phpDocumentor\Transformer\Router\Rule::translateToUrlEncodedPath
63
     */
64
    public function testTranslateToUrlEncodedPath()
65
    {
66
        $fixture = new Rule(
67
            function () {
68
                return true;
69
            },
70
            function () {
71
                return 'httö://www.€xample.org/foo.html#bär';
72
            }
73
        );
74
75
        $this->assertSame('httö://www.EURxample.org/foo.html#bär', $fixture->generate('test'));
76
    }
77
}
78