File tree 3 files changed +48
-0
lines changed
spec/drupol/phptree/Exporter
3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 5
5
namespace spec \drupol \phptree \Exporter ;
6
6
7
7
use drupol \phptree \Exporter \Ascii ;
8
+ use drupol \phptree \Node \Node ;
8
9
use drupol \phptree \Node \ValueNode ;
9
10
use PhpSpec \ObjectBehavior ;
10
11
@@ -99,4 +100,19 @@ public function it_can_export_to_ascii()
99
100
->export ($ tree )
100
101
->shouldReturn ($ expected );
101
102
}
103
+
104
+ public function it_can_throw_an_error_when_tree_is_not_a_valuenode ()
105
+ {
106
+ $ tree = new Node ();
107
+
108
+ foreach (\range ('A ' , 'Z ' ) as $ key => $ value ) {
109
+ $ nodes [$ value ] = new Node ();
110
+ }
111
+
112
+ $ tree ->add (...\array_values ($ nodes ));
113
+
114
+ $ this
115
+ ->shouldThrow (\InvalidArgumentException::class)
116
+ ->during ('export ' , [$ tree ]);
117
+ }
102
118
}
Original file line number Diff line number Diff line change 5
5
namespace spec \drupol \phptree \Exporter ;
6
6
7
7
use drupol \phptree \Exporter \SimpleArray ;
8
+ use drupol \phptree \Node \Node ;
8
9
use drupol \phptree \Node \ValueNode ;
9
10
use PhpSpec \ObjectBehavior ;
10
11
@@ -78,4 +79,19 @@ public function it_can_export_to_an_array()
78
79
->export ($ tree )
79
80
->shouldReturn ($ return );
80
81
}
82
+
83
+ public function it_can_throw_an_error_when_tree_is_not_a_valuenode ()
84
+ {
85
+ $ tree = new Node ();
86
+
87
+ foreach (\range ('A ' , 'Z ' ) as $ key => $ value ) {
88
+ $ nodes [$ value ] = new Node ();
89
+ }
90
+
91
+ $ tree ->add (...\array_values ($ nodes ));
92
+
93
+ $ this
94
+ ->shouldThrow (\InvalidArgumentException::class)
95
+ ->during ('export ' , [$ tree ]);
96
+ }
81
97
}
Original file line number Diff line number Diff line change 5
5
namespace spec \drupol \phptree \Exporter ;
6
6
7
7
use drupol \phptree \Exporter \Text ;
8
+ use drupol \phptree \Node \Node ;
8
9
use drupol \phptree \Node \ValueNode ;
9
10
use PhpSpec \ObjectBehavior ;
10
11
@@ -34,4 +35,19 @@ public function it_can_export_to_text()
34
35
->export ($ tree )
35
36
->shouldReturn ('[root [A [C [G] [H]] [D [I] [J]]] [B [E] [F]]] ' );
36
37
}
38
+
39
+ public function it_can_throw_an_error_when_tree_is_not_a_valuenode ()
40
+ {
41
+ $ tree = new Node ();
42
+
43
+ foreach (\range ('A ' , 'Z ' ) as $ key => $ value ) {
44
+ $ nodes [$ value ] = new Node ();
45
+ }
46
+
47
+ $ tree ->add (...\array_values ($ nodes ));
48
+
49
+ $ this
50
+ ->shouldThrow (\InvalidArgumentException::class)
51
+ ->during ('export ' , [$ tree ]);
52
+ }
37
53
}
You can’t perform that action at this time.
0 commit comments