|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
|
4
|
|
|
|
|
5
|
|
|
namespace spec\byrokrat\autogiro\Tree; |
|
6
|
|
|
|
|
7
|
|
|
use byrokrat\autogiro\Tree\FileNode; |
|
8
|
|
|
use byrokrat\autogiro\Tree\LayoutNode; |
|
9
|
|
|
use byrokrat\autogiro\Tree\Node; |
|
10
|
|
|
use byrokrat\autogiro\Visitor; |
|
11
|
|
|
use byrokrat\autogiro\Exception\LogicException; |
|
12
|
|
|
use PhpSpec\ObjectBehavior; |
|
13
|
|
|
|
|
14
|
|
|
class FileNodeSpec extends ObjectBehavior |
|
15
|
|
|
{ |
|
16
|
|
|
function let(LayoutNode $layoutA, LayoutNode $layoutB) |
|
17
|
|
|
{ |
|
18
|
|
|
$this->beConstructedWith($layoutA, $layoutB); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
function it_is_initializable() |
|
22
|
|
|
{ |
|
23
|
|
|
$this->shouldHaveType(FileNode::CLASS); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
function it_implements_node_interface() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->shouldHaveType(Node::CLASS); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
function it_accepts_a_visitor($layoutA, $layoutB, Visitor $visitor) |
|
32
|
|
|
{ |
|
33
|
|
|
$visitor->visitBefore($this)->shouldBeCalled(); |
|
34
|
|
|
$layoutA->accept($visitor)->shouldBeCalled(); |
|
35
|
|
|
$layoutB->accept($visitor)->shouldBeCalled(); |
|
36
|
|
|
$visitor->visitAfter($this)->shouldBeCalled(); |
|
37
|
|
|
|
|
38
|
|
|
$this->accept($visitor); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
function it_contains_a_type() |
|
42
|
|
|
{ |
|
43
|
|
|
$this->getType()->shouldEqual('FileNode'); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
function it_contains_layouts($layoutA, $layoutB) |
|
47
|
|
|
{ |
|
48
|
|
|
$this->getChildren()->shouldEqual(['1' => $layoutA, '2' => $layoutB]); |
|
49
|
|
|
$this->getChild('1')->shouldEqual($layoutA); |
|
50
|
|
|
$this->getChild('2')->shouldEqual($layoutB); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
function it_throws_exception_if_index_is_out_of_range() |
|
54
|
|
|
{ |
|
55
|
|
|
$this->shouldThrow(LogicException::CLASS)->duringGetChild('100'); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
function it_contains_a_line_number($layoutA) |
|
59
|
|
|
{ |
|
60
|
|
|
$layoutA->getLineNr()->willReturn(15); |
|
61
|
|
|
$this->getLineNr()->shouldEqual(15); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|