Test Failed
Push — master ( 72a6c5...9329b7 )
by Arun
03:52
created

InterpretingDocBlocksTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 75
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testInterpretingASimpleDocBlock() 0 22 1
A testInterpretingTags() 0 21 1
B testDescriptionsCanEscapeAtSignsAndClosingBraces() 0 27 1
1
<?php
2
/**
3
 * This file is part of phpDocumentor.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @copyright 2010-2015 Mike van Riel<[email protected]>
9
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
10
 * @link      http://phpdoc.org
11
 */
12
13
namespace phpDocumentor\Reflection;
14
15
use phpDocumentor\Reflection\DocBlock\Description;
16
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
17
use phpDocumentor\Reflection\DocBlock\Tag;
18
use phpDocumentor\Reflection\DocBlock\Tags\See;
19
20
/**
21
 * @coversNothing
22
 */
23
class InterpretingDocBlocksTest extends \PHPUnit_Framework_TestCase
24
{
25
    public function testInterpretingASimpleDocBlock()
26
    {
27
        /**
28
         * @var DocBlock    $docblock
29
         * @var string      $summary
30
         * @var Description $description
31
         */
32
        include(__DIR__ . '/../../examples/01-interpreting-a-simple-docblock.php');
33
34
        $descriptionText = <<<DESCRIPTION
35
This is a Description. A Summary and Description are separated by either
36
two subsequent newlines (thus a whiteline in between as can be seen in this
37
example), or when the Summary ends with a dot (`.`) and some form of
38
whitespace.
39
DESCRIPTION;
40
41
        $this->assertInstanceOf(DocBlock::class, $docblock);
0 ignored issues
show
Bug introduced by
The variable $docblock does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
42
        $this->assertSame('This is an example of a summary.', $summary);
0 ignored issues
show
Bug introduced by
The variable $summary does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
43
        $this->assertInstanceOf(Description::class, $description);
0 ignored issues
show
Bug introduced by
The variable $description does not exist. Did you mean $descriptionText?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
44
        $this->assertSame($descriptionText, $description->render());
0 ignored issues
show
Bug introduced by
The variable $description does not exist. Did you mean $descriptionText?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
45
        $this->assertEmpty($docblock->getTags());
46
    }
47
48
    public function testInterpretingTags()
49
    {
50
        /**
51
         * @var DocBlock $docblock
52
         * @var boolean  $hasSeeTag
53
         * @var Tag[]    $tags
54
         * @var See[]    $seeTags
55
         */
56
        include(__DIR__ . '/../../examples/02-interpreting-tags.php');
57
58
        $this->assertTrue($hasSeeTag);
0 ignored issues
show
Bug introduced by
The variable $hasSeeTag does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
59
        $this->assertCount(1, $tags);
0 ignored issues
show
Bug introduced by
The variable $tags does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
60
        $this->assertCount(1, $seeTags);
0 ignored issues
show
Bug introduced by
The variable $seeTags does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
61
62
        $this->assertInstanceOf(See::class, $tags[0]);
63
        $this->assertInstanceOf(See::class, $seeTags[0]);
64
65
        $seeTag = $seeTags[0];
66
        $this->assertSame('\\' . StandardTagFactory::class, (string)$seeTag->getReference());
67
        $this->assertSame('', (string)$seeTag->getDescription());
68
    }
69
70
    public function testDescriptionsCanEscapeAtSignsAndClosingBraces()
71
    {
72
        /**
73
         * @var string      $docComment
74
         * @var DocBlock    $docblock
75
         * @var Description $description
76
         * @var string      $receivedDocComment
77
         * @var string      $foundDescription
78
         */
79
80
        include(__DIR__ . '/../../examples/playing-with-descriptions/02-escaping.php');
81
        $this->assertSame(<<<'DESCRIPTION'
82
You can escape the @-sign by surrounding it with braces, for example: @. And escape a closing brace within an
83
inline tag by adding an opening brace in front of it like this: }.
84
85
Here are example texts where you can see how they could be used in a real life situation:
86
87
    This is a text with an {@internal inline tag where a closing brace (}) is shown}.
88
    Or an {@internal inline tag with a literal {@link} in it}.
89
90
Do note that an {@internal inline tag that has an opening brace ({) does not break out}.
91
DESCRIPTION
92
            ,
93
            $foundDescription
0 ignored issues
show
Bug introduced by
The variable $foundDescription does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
94
        )
95
        ;
96
    }
97
}
98