Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Aug 30, 2020
1 parent 126994f commit a7c1ff3
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions spec/loophp/collection/CollectionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1212,12 +1200,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
Expand Down Expand Up @@ -1673,7 +1663,7 @@ public function __invoke(): Closure
};

$this::fromIterable(range(1, 5))
->run($square, $sqrt, $map)
->run($square(), $sqrt(), $map())
->shouldIterateAs(range(1, 5));
}

Expand Down Expand Up @@ -2087,16 +2077,20 @@ 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
{
$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]);
Expand Down

0 comments on commit a7c1ff3

Please sign in to comment.