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

GenericNodeTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test_it_can_be_created_with_a_name_and_value() 0 7 1
A test_it_can_have_options() 0 11 1
A test_you_can_pass_classes_for_in_templates() 0 10 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 GenericNodeTest extends TestCase
19
{
20
    public function test_it_can_be_created_with_a_name_and_value() : void
21
    {
22
        $node = new GenericNode('name', 'value');
23
24
        self::assertSame('name', $node->getName());
25
        self::assertSame('value', $node->getValue());
26
    }
27
28
    public function test_it_can_have_options() : void
29
    {
30
        $option = 'option';
31
32
        $node = new GenericNode('name', 'value');
33
        $nodeWithOptions = $node->withOptions(['option' => $option]);
34
35
        // also test immutability to be sure
36
        self::assertNull($node->getOption('option'));
37
        self::assertSame($option, $nodeWithOptions->getOption('option'));
38
    }
39
40
    public function test_you_can_pass_classes_for_in_templates() : void
41
    {
42
        $classes = ['generic', 'node'];
43
44
        $node = new GenericNode('name', 'value');
45
        $node->setClasses($classes);
46
47
        self::assertSame($classes, $node->getClasses());
48
        self::assertSame('generic node', $node->getClassesString());
49
    }
50
}
51