From 7f587ed7650557cd2c9b4cbad9d5c5d4b995253c Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Wed, 26 Aug 2020 21:21:55 +0200 Subject: [PATCH] Update tests. --- spec/loophp/collection/CollectionSpec.php | 28 +++++++++-------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/spec/loophp/collection/CollectionSpec.php b/spec/loophp/collection/CollectionSpec.php index 0dbe47806..c1cbcfb59 100644 --- a/spec/loophp/collection/CollectionSpec.php +++ b/spec/loophp/collection/CollectionSpec.php @@ -13,7 +13,6 @@ use JsonSerializable; use loophp\collection\Collection; use loophp\collection\Contract\Operation; -use loophp\collection\Contract\Transformation; use loophp\collection\Operation\AbstractOperation; use PhpSpec\ObjectBehavior; use stdClass; @@ -238,17 +237,6 @@ public function it_can_be_json_encoded() $this ->shouldImplement(JsonSerializable::class); - - $this - ->transform( - new class() implements Transformation { - public function __invoke(Iterator $collection) - { - return '{"a":"A","b":"B","c":"C"}'; - } - } - ) - ->shouldReturn(json_encode($this->getWrappedObject())); } public function it_can_be_returned_as_an_array(): void @@ -1177,12 +1165,14 @@ public function it_can_intersperse(): void ->shouldIterateAs($generator()); $this::fromIterable(range('A', 'F')) + ->intersperse('foo', -1, 1) ->shouldThrow(Exception::class) - ->during('intersperse', ['foo', -1, 1]); + ->during('all'); $this::fromIterable(range('A', 'F')) + ->intersperse('foo', 1, -1) ->shouldThrow(Exception::class) - ->during('intersperse', ['foo', 1, -1]); + ->during('all'); } public function it_can_iterate(): void @@ -1641,7 +1631,7 @@ public function __invoke(): Closure }; $this::fromIterable(range(1, 5)) - ->run($square, $sqrt, $map) + ->run($square(), $sqrt(), $map()) ->shouldIterateAs(range(1, 5)); } @@ -2055,6 +2045,10 @@ public function it_can_use_times_with_a_callback(): void return range(1, 5); }) ->shouldIterateAs($a); + + $this::times(-1, 'count') + ->shouldThrow(InvalidArgumentException::class) + ->during('all'); } public function it_can_use_times_without_a_callback(): void @@ -2062,9 +2056,9 @@ public function it_can_use_times_without_a_callback(): void $this::times(10) ->shouldIterateAs(range(1, 10)); - $this::times(10) + $this::times(-5) ->shouldThrow(InvalidArgumentException::class) - ->during('times', [-5]); + ->during('all'); $this::times(1) ->shouldIterateAs([1]);