Completed
Push — develop ( efa997...824f66 )
by Jaap
10:28
created

testFqsenDescriptorReturnsFalseWhenNodeOfWrongType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 12
rs 9.4285
c 1
b 0
f 0
1
<?php
2
/**
3
 * phpDocumentor
4
 *
5
 * PHP Version 5.3
6
 *
7
 * @copyright 2010-2014 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\UrlGenerator\Standard;
13
14
use Mockery as m;
15
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen;
16
use phpDocumentor\Reflection\Fqsen as RealFqsen;
17
18
/**
19
 * Test for the MethodDescriptor URL Generator with the Standard Router
20
 */
21
class FqsenDescriptorTest extends \PHPUnit_Framework_TestCase
22
{
23
    /**
24
     * @covers phpDocumentor\Transformer\Router\UrlGenerator\Standard\FqsenDescriptor::__invoke
25
     * @covers phpDocumentor\Transformer\Router\UrlGenerator\Standard\QualifiedNameToUrlConverter::fromClass
26
     * @dataProvider provideFqsens
27
     */
28
    public function testGenerateUrlForFqsenDescriptor($fromFqsen, $toPath)
29
    {
30
        // Arrange
31
        $realFqsen = new RealFqsen($fromFqsen);
32
        $fqsen = new Fqsen($realFqsen);
33
        $fixture = new FqsenDescriptor();
34
35
        // Act
36
        $result = $fixture($fqsen);
37
38
        // Assert
39
        $this->assertSame($toPath, $result);
40
    }
41
42
    /**
43
     * @covers phpDocumentor\Transformer\Router\UrlGenerator\Standard\FqsenDescriptor::__invoke
44
     */
45
    public function testFqsenDescriptorReturnsFalseWhenNodeOfWrongType()
46
    {
47
        // Arrange
48
        $fqsen = m::mock('phpDocumentor\Reflection\DocBlock\Tags\Reference\Reference');
49
        $fixture = new FqsenDescriptor();
50
51
        // Act
52
        $result = $fixture($fqsen);
53
54
        // Assert
55
        $this->assertSame(false, $result);
56
    }
57
58
    public function provideFqsens()
59
    {
60
        return array(
61
            array('\\My\\Space\\Class', '/classes/My.Space.Class.html'),
62
            array('\\My\\Space\\Class::$property', '/classes/My.Space.Class.html#property_property'),
63
            array('\\My\\Space\\Class::method()', '/classes/My.Space.Class.html#method_method'),
64
            array('\\My\\Space\\Class::CONSTANT', '/classes/My.Space.Class.html#constant_CONSTANT'),
65
        );
66
    }
67
}
68