Completed
Push — master ( fee60c...6071cd )
by Mike
03:05
created

CodeNodeTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 54
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A test_it_can_be_created_with_series_of_lines() 0 7 1
A test_a_language_can_be_provided() 0 8 1
A test_a_starting_line_number_can_be_provided() 0 8 1
A test_lines_are_normalized_by_removing_whitespace() 0 12 1
A test_that_normalizing_keeps_spaces_intact_when_the_first_line_has_no_spaces() 0 12 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace phpDocumentor\Guides\Nodes;
6
7
/**
8
 * This file is part of phpDocumentor.
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 *
13
 * @link https://phpdoc.org
14
 */
15
16
use PHPUnit\Framework\TestCase;
17
18
final class CodeNodeTest extends TestCase
19
{
20
    public function test_it_can_be_created_with_series_of_lines() : void
21
    {
22
        $node = new CodeNode(['line1', 'line2']);
23
24
        self::assertSame("line1\nline2", $node->getValue());
25
        self::assertSame("line1\nline2", $node->getValueString());
26
    }
27
28
    public function test_a_language_can_be_provided() : void
29
    {
30
        $node = new CodeNode([]);
31
        self::assertNull($node->getLanguage());
32
        $node->setLanguage('php');
33
34
        self::assertSame('php', $node->getLanguage());
35
    }
36
37
    public function test_a_starting_line_number_can_be_provided() : void
38
    {
39
        $node = new CodeNode([]);
40
        self::assertNull($node->getStartingLineNumber());
41
        $node->setStartingLineNumber(100);
42
43
        self::assertSame(100, $node->getStartingLineNumber());
44
    }
45
46
    public function test_lines_are_normalized_by_removing_whitespace() : void
47
    {
48
        $node = new CodeNode([
49
            '  line1',
50
            '    line2',
51
            '      line3',
52
            "\t\t\tline4",
53
        ]);
54
55
        self::assertSame("line1\n  line2\n    line3\n\tline4", $node->getValue());
56
        self::assertSame("line1\n  line2\n    line3\n\tline4", $node->getValueString());
57
    }
58
59
    public function test_that_normalizing_keeps_spaces_intact_when_the_first_line_has_no_spaces() : void
60
    {
61
        $node = new CodeNode([
62
            'line1',
63
            '  line2',
64
            '    line3',
65
            "\t\t\tline4",
66
        ]);
67
68
        self::assertSame("line1\n  line2\n    line3\n\t\t\tline4", $node->getValue());
69
        self::assertSame("line1\n  line2\n    line3\n\t\t\tline4", $node->getValueString());
70
    }
71
}
72