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

test_you_can_pass_classes_for_in_templates()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
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 ImageNodeTest extends TestCase
19
{
20
    public function test_it_can_be_created_with_a_url() : void
21
    {
22
        $url = 'https://example.com/images/image1.jpg';
23
24
        $node = new ImageNode($url);
25
26
        self::assertSame($url, $node->getValue());
27
    }
28
29
    public function test_it_can_have_a_width_and_height() : void
30
    {
31
        $width = '10';
32
        $height = '20';
33
34
        $node = new ImageNode();
35
        $nodeWithOptions = $node->withOptions(['width' => $width, 'height' => $height]);
36
37
        // also test immutability to be sure
38
        self::assertNull($node->getOption('width'));
39
        self::assertNull($node->getOption('height'));
40
        self::assertSame($width, $nodeWithOptions->getOption('width'));
41
        self::assertSame($height, $nodeWithOptions->getOption('height'));
42
    }
43
44
    public function test_it_can_have_an_alt_text() : void
45
    {
46
        $alt = 'alt text';
47
48
        $node = new ImageNode();
49
        $nodeWithOptions = $node->withOptions(['alt' => $alt]);
50
51
        // also test immutability to be sure
52
        self::assertNull($node->getOption('alt'));
53
        self::assertSame($alt, $nodeWithOptions->getOption('alt'));
54
    }
55
56
    public function test_it_can_have_an_alignment() : void
57
    {
58
        $align = 'left';
59
60
        $node = new ImageNode();
61
        $nodeWithOptions = $node->withOptions(['align' => $align]);
62
63
        // also test immutability to be sure
64
        self::assertNull($node->getOption('align'));
65
        self::assertSame($align, $nodeWithOptions->getOption('align'));
66
    }
67
68
    public function test_you_can_pass_classes_for_in_templates() : void
69
    {
70
        $classes = ['image', 'node'];
71
72
        $node = new ImageNode();
73
        $node->setClasses($classes);
74
75
        self::assertSame($classes, $node->getClasses());
76
        self::assertSame('image node', $node->getClassesString());
77
    }
78
}
79