-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
MultipleIterableIteratorSpec.php
60 lines (42 loc) · 1.41 KB
/
MultipleIterableIteratorSpec.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace spec\loophp\collection\Iterator;
use ArrayIterator;
use Generator;
use loophp\collection\Iterator\MultipleIterableIterator;
use PhpSpec\ObjectBehavior;
class MultipleIterableIteratorSpec extends ObjectBehavior
{
public function it_can_iterate_with_a_single_iterable(): void
{
$this->beConstructedWith([1, 2, 3]);
$this->getInnerIterator()->shouldIterateAs([1, 2, 3]);
}
public function it_can_iterate_with_multiple_iterables(): void
{
$this->beConstructedWith([1, 2, 3], new ArrayIterator([4, 5, 6]));
$expected = static function (): Generator {
yield 0 => 1;
yield 1 => 2;
yield 2 => 3;
yield 0 => 4;
yield 1 => 5;
yield 2 => 6;
};
$this->getInnerIterator()->shouldIterateAs($expected());
}
public function it_is_initializable_with_a_single_iterable(): void
{
$this->beConstructedWith([1, 2, 3]);
$this->shouldHaveType(MultipleIterableIterator::class);
}
public function it_is_initializable_with_multiple_iterables(): void
{
$this->beConstructedWith([1, 2, 3], new ArrayIterator([4, 5, 6]));
$this->shouldHaveType(MultipleIterableIterator::class);
}
}