Skip to content

Commit 79fd15b

Browse files
committed
Add tests.
1 parent 8c29f58 commit 79fd15b

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace spec\drupol\phptree\Modifier;
6+
7+
use drupol\phptree\Modifier\FulfillCapacity;
8+
use drupol\phptree\Node\ValueNode;
9+
use PhpSpec\ObjectBehavior;
10+
11+
class FulfillCapacitySpec extends ObjectBehavior
12+
{
13+
public function it_can_fulfill_missing_node()
14+
{
15+
$tree = new ValueNode('root', 10);
16+
17+
$nodes = [];
18+
19+
foreach (range('A', 'E') as $value) {
20+
$nodes[] = new ValueNode($value);
21+
}
22+
$tree->add(...$nodes);
23+
24+
$this
25+
->modify($tree)
26+
->count()
27+
->shouldReturn(10);
28+
}
29+
30+
public function it_is_initializable()
31+
{
32+
$this->shouldHaveType(FulfillCapacity::class);
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace spec\drupol\phptree\Modifier;
6+
7+
use drupol\phptree\Modifier\RemoveNullNode;
8+
use drupol\phptree\Node\ValueNode;
9+
use PhpSpec\ObjectBehavior;
10+
11+
class RemoveNullNodeSpec extends ObjectBehavior
12+
{
13+
public function it_can_remove_node_with_null_values()
14+
{
15+
$tree = new ValueNode('root', 10);
16+
17+
$nodes = [];
18+
19+
foreach ([null, null, null, 'a', 'b', null, 'c'] as $value) {
20+
$nodes[] = new ValueNode($value);
21+
}
22+
$tree->add(...$nodes);
23+
24+
$this
25+
->modify($tree)
26+
->count()
27+
->shouldReturn(3);
28+
}
29+
30+
public function it_is_initializable()
31+
{
32+
$this->shouldHaveType(RemoveNullNode::class);
33+
}
34+
}

0 commit comments

Comments
 (0)