Skip to content

Commit 437397f

Browse files
committed
Update tests.
1 parent f1ecb6a commit 437397f

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

spec/drupol/phptree/Exporter/GraphSpec.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ class GraphSpec extends ObjectBehavior
1313
{
1414
public function it_can_generate_a_graph()
1515
{
16-
$root = new ValueNode('root');
17-
$child1 = new ValueNode();
18-
$child2 = new ValueNode();
19-
$child3 = new ValueNode();
20-
$root
16+
$tree = new ValueNode('root');
17+
$child1 = new ValueNode('child1');
18+
$child2 = new ValueNode('child2');
19+
$child3 = new ValueNode('child3');
20+
$tree
2121
->add($child1, $child2, $child3);
2222

2323
$this
24-
->export($root)
24+
->export($tree)
2525
->shouldReturnAnInstanceOf(\Fhaculty\Graph\Graph::class);
2626

2727
$this
@@ -36,7 +36,7 @@ public function it_can_generate_a_graph()
3636

3737
$traverser = new BreadthFirst();
3838

39-
$nodes = \iterator_to_array($traverser->traverse($root));
39+
$nodes = \iterator_to_array($traverser->traverse($tree));
4040

4141
for ($i = 0; \count($nodes) - 1 > $i; ++$i) {
4242
$node0 = $nodes[0];

spec/drupol/phptree/Node/NaryNodeSpec.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ public function it_can_be_counted()
1414
$this->beConstructedWith(2);
1515

1616
foreach (\range('A', 'Z') as $value) {
17-
$node = new NaryNode(2);
18-
19-
$this->add($node);
17+
$this->add(new NaryNode(2));
2018
}
2119

2220
$this

spec/drupol/phptree/Node/NodeSpec.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use drupol\phptree\Node\Node;
88
use drupol\phptree\Node\NodeInterface;
9+
use drupol\phptree\Node\ValueNode;
910
use PhpSpec\ObjectBehavior;
1011

1112
class NodeSpec extends ObjectBehavior
@@ -114,7 +115,7 @@ public function it_can_get_its_depth()
114115
->depth()
115116
->shouldReturn(0);
116117

117-
$tree = new \drupol\phptree\Node\ValueNode('root', 2);
118+
$tree = new ValueNode('root', 2);
118119

119120
$tree->add($this->getWrappedObject());
120121

@@ -124,16 +125,14 @@ public function it_can_get_its_depth()
124125

125126
$nodes = [];
126127
foreach (\range('A', 'Z') as $v) {
127-
$nodes[] = new \drupol\phptree\Node\ValueNode($v, 2);
128+
$nodes[] = new ValueNode($v, 2);
128129
}
129130

130131
$tree->add(...$nodes);
131132

132-
$tree->add($this->getWrappedObject());
133-
134133
$this
135134
->depth()
136-
->shouldReturn(4);
135+
->shouldReturn(1);
137136
}
138137

139138
public function it_can_get_its_height()
@@ -144,7 +143,7 @@ public function it_can_get_its_height()
144143

145144
$tree = $this;
146145
foreach (\range('A', 'B') as $key => $v) {
147-
$node = new \drupol\phptree\Node\ValueNode($v, 1);
146+
$node = new ValueNode($v, 1);
148147
$tree->add($node);
149148
$tree = $node;
150149
}
@@ -154,7 +153,7 @@ public function it_can_get_its_height()
154153
->shouldReturn(2);
155154

156155
foreach (\range('C', 'F') as $key => $v) {
157-
$node = new \drupol\phptree\Node\ValueNode($v, 1);
156+
$node = new ValueNode($v, 1);
158157
$tree->add($node);
159158
$tree = $node;
160159
}

spec/drupol/phptree/Node/ValueNodeSpec.php

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public function it_can_be_set_with_a_value()
2121

2222
public function it_is_initializable()
2323
{
24+
$this
25+
->beConstructedWith('root');
26+
2427
$this->shouldHaveType(ValueNode::class);
2528

2629
$this->children()->shouldYield(new \ArrayIterator([]));

0 commit comments

Comments
 (0)