Skip to content

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Dec 12, 2019
1 parent 8c29f58 commit 79fd15b
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
34 changes: 34 additions & 0 deletions spec/drupol/phptree/Modifier/FulfillCapacitySpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace spec\drupol\phptree\Modifier;

use drupol\phptree\Modifier\FulfillCapacity;
use drupol\phptree\Node\ValueNode;
use PhpSpec\ObjectBehavior;

class FulfillCapacitySpec extends ObjectBehavior
{
public function it_can_fulfill_missing_node()
{
$tree = new ValueNode('root', 10);

$nodes = [];

foreach (range('A', 'E') as $value) {
$nodes[] = new ValueNode($value);
}
$tree->add(...$nodes);

$this
->modify($tree)
->count()
->shouldReturn(10);
}

public function it_is_initializable()
{
$this->shouldHaveType(FulfillCapacity::class);
}
}
34 changes: 34 additions & 0 deletions spec/drupol/phptree/Modifier/RemoveNullNodeSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace spec\drupol\phptree\Modifier;

use drupol\phptree\Modifier\RemoveNullNode;
use drupol\phptree\Node\ValueNode;
use PhpSpec\ObjectBehavior;

class RemoveNullNodeSpec extends ObjectBehavior
{
public function it_can_remove_node_with_null_values()
{
$tree = new ValueNode('root', 10);

$nodes = [];

foreach ([null, null, null, 'a', 'b', null, 'c'] as $value) {
$nodes[] = new ValueNode($value);
}
$tree->add(...$nodes);

$this
->modify($tree)
->count()
->shouldReturn(3);
}

public function it_is_initializable()
{
$this->shouldHaveType(RemoveNullNode::class);
}
}

0 comments on commit 79fd15b

Please sign in to comment.