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
|
|
|
|