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