Skip to content

Commit

Permalink
tests: Add more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Dec 17, 2020
1 parent af7ee07 commit 8fc51fd
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions spec/loophp/collection/CollectionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace spec\loophp\collection;

use ArrayIterator;
use ArrayObject;
use Closure;
use Exception;
Expand Down Expand Up @@ -205,6 +206,25 @@ public function it_can_be_constructed_from_a_file(): void
]);
}

public function it_can_be_constructed_from_a_generator(): void
{
$generator = static function () {
yield 'a';

yield 'b';

yield 'c';

yield 'd';

yield 'e';
};

$this::fromIterable($generator())
->getIterator()
->shouldIterateAs(range('a', 'e'));
}

public function it_can_be_constructed_from_a_stream(): void
{
$string = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
Expand Down Expand Up @@ -264,6 +284,13 @@ public function it_can_be_constructed_from_an_iterable(): void
]);
}

public function it_can_be_constructed_from_an_iterator(): void
{
$this::fromIterable(new ArrayIterator(range('a', 'e')))
->getIterator()
->shouldIterateAs(range('a', 'e'));
}

public function it_can_be_constructed_from_empty(): void
{
$this
Expand Down

0 comments on commit 8fc51fd

Please sign in to comment.