Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed May 2, 2019
1 parent f1ecb6a commit 437397f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions spec/drupol/phptree/Exporter/GraphSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ class GraphSpec extends ObjectBehavior
{
public function it_can_generate_a_graph()
{
$root = new ValueNode('root');
$child1 = new ValueNode();
$child2 = new ValueNode();
$child3 = new ValueNode();
$root
$tree = new ValueNode('root');
$child1 = new ValueNode('child1');
$child2 = new ValueNode('child2');
$child3 = new ValueNode('child3');
$tree
->add($child1, $child2, $child3);

$this
->export($root)
->export($tree)
->shouldReturnAnInstanceOf(\Fhaculty\Graph\Graph::class);

$this
Expand All @@ -36,7 +36,7 @@ public function it_can_generate_a_graph()

$traverser = new BreadthFirst();

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

for ($i = 0; \count($nodes) - 1 > $i; ++$i) {
$node0 = $nodes[0];
Expand Down
4 changes: 1 addition & 3 deletions spec/drupol/phptree/Node/NaryNodeSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ public function it_can_be_counted()
$this->beConstructedWith(2);

foreach (\range('A', 'Z') as $value) {
$node = new NaryNode(2);

$this->add($node);
$this->add(new NaryNode(2));
}

$this
Expand Down
13 changes: 6 additions & 7 deletions spec/drupol/phptree/Node/NodeSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use drupol\phptree\Node\Node;
use drupol\phptree\Node\NodeInterface;
use drupol\phptree\Node\ValueNode;
use PhpSpec\ObjectBehavior;

class NodeSpec extends ObjectBehavior
Expand Down Expand Up @@ -114,7 +115,7 @@ public function it_can_get_its_depth()
->depth()
->shouldReturn(0);

$tree = new \drupol\phptree\Node\ValueNode('root', 2);
$tree = new ValueNode('root', 2);

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

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

$nodes = [];
foreach (\range('A', 'Z') as $v) {
$nodes[] = new \drupol\phptree\Node\ValueNode($v, 2);
$nodes[] = new ValueNode($v, 2);
}

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

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

$this
->depth()
->shouldReturn(4);
->shouldReturn(1);
}

public function it_can_get_its_height()
Expand All @@ -144,7 +143,7 @@ public function it_can_get_its_height()

$tree = $this;
foreach (\range('A', 'B') as $key => $v) {
$node = new \drupol\phptree\Node\ValueNode($v, 1);
$node = new ValueNode($v, 1);
$tree->add($node);
$tree = $node;
}
Expand All @@ -154,7 +153,7 @@ public function it_can_get_its_height()
->shouldReturn(2);

foreach (\range('C', 'F') as $key => $v) {
$node = new \drupol\phptree\Node\ValueNode($v, 1);
$node = new ValueNode($v, 1);
$tree->add($node);
$tree = $node;
}
Expand Down
3 changes: 3 additions & 0 deletions spec/drupol/phptree/Node/ValueNodeSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public function it_can_be_set_with_a_value()

public function it_is_initializable()
{
$this
->beConstructedWith('root');

$this->shouldHaveType(ValueNode::class);

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

0 comments on commit 437397f

Please sign in to comment.