Skip to content

Commit 2a7941c

Browse files
committed
Fix test coverage.
1 parent f422c8b commit 2a7941c

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

spec/drupol/phptree/Exporter/AsciiSpec.php

+16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace spec\drupol\phptree\Exporter;
66

77
use drupol\phptree\Exporter\Ascii;
8+
use drupol\phptree\Node\Node;
89
use drupol\phptree\Node\ValueNode;
910
use PhpSpec\ObjectBehavior;
1011

@@ -99,4 +100,19 @@ public function it_can_export_to_ascii()
99100
->export($tree)
100101
->shouldReturn($expected);
101102
}
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+
}
102118
}

spec/drupol/phptree/Exporter/SimpleArraySpec.php

+16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace spec\drupol\phptree\Exporter;
66

77
use drupol\phptree\Exporter\SimpleArray;
8+
use drupol\phptree\Node\Node;
89
use drupol\phptree\Node\ValueNode;
910
use PhpSpec\ObjectBehavior;
1011

@@ -78,4 +79,19 @@ public function it_can_export_to_an_array()
7879
->export($tree)
7980
->shouldReturn($return);
8081
}
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+
}
8197
}

spec/drupol/phptree/Exporter/TextSpec.php

+16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace spec\drupol\phptree\Exporter;
66

77
use drupol\phptree\Exporter\Text;
8+
use drupol\phptree\Node\Node;
89
use drupol\phptree\Node\ValueNode;
910
use PhpSpec\ObjectBehavior;
1011

@@ -34,4 +35,19 @@ public function it_can_export_to_text()
3435
->export($tree)
3536
->shouldReturn('[root [A [C [G] [H]] [D [I] [J]]] [B [E] [F]]]');
3637
}
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+
}
3753
}

0 commit comments

Comments
 (0)