5
5
namespace spec \drupol \phptree \Node ;
6
6
7
7
use drupol \phptree \Node \NaryNode ;
8
+ use drupol \phptree \Node \Node ;
8
9
use drupol \phptree \Node \ValueNode ;
10
+ use drupol \phptree \Traverser \BreadthFirst ;
11
+ use drupol \phptree \Traverser \PreOrder ;
9
12
use drupol \phptree \Traverser \TraverserInterface ;
10
13
11
14
class NaryNodeSpec extends NodeObjectBehavior
@@ -44,6 +47,25 @@ public function it_can_get_the_capacity_when_using_a_custom_capacity()
44
47
->shouldReturn (3 );
45
48
}
46
49
50
+ public function it_can_have_children ()
51
+ {
52
+ $ this ->beConstructedWith (2 );
53
+
54
+ $ child1 = new Node ();
55
+ $ child2 = new NaryNode (2 );
56
+ $ child3 = new Node ();
57
+ $ child4 = new Node ();
58
+ $ child5 = new Node ();
59
+ $ child6 = new Node ();
60
+ $ child7 = new Node ();
61
+
62
+ $ this
63
+ ->add ($ child1 , $ child2 , $ child3 , $ child4 , $ child5 , $ child6 , $ child7 );
64
+
65
+ $ this ->degree ()->shouldReturn (2 );
66
+ $ this ->count ()->shouldReturn (4 );
67
+ }
68
+
47
69
public function it_can_throw_an_error_when_capacity_is_invalid ()
48
70
{
49
71
$ this ->beConstructedWith (-5 );
@@ -53,8 +75,17 @@ public function it_can_throw_an_error_when_capacity_is_invalid()
53
75
->shouldReturn (0 );
54
76
}
55
77
78
+ public function it_can_use_a_different_traverser ()
79
+ {
80
+ $ this ->beConstructedWith (2 , null , new PreOrder ());
81
+
82
+ $ this ->getTraverser ()->shouldBeAnInstanceOf (PreOrder::class);
83
+ }
84
+
56
85
public function it_is_initializable ()
57
86
{
58
87
$ this ->shouldHaveType (NaryNode::class);
88
+
89
+ $ this ->getTraverser ()->shouldBeAnInstanceOf (BreadthFirst::class);
59
90
}
60
91
}
0 commit comments