Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Fixed issue with InvalidArgumentException when a string is passed as …
Browse files Browse the repository at this point in the history
…chunk-size.
  • Loading branch information
mburtscher authored and davidroth committed Nov 15, 2016
1 parent bff72e2 commit 659b714
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Fusonic/Linq/Linq.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function aggregate(callable $func, $seed = null)
public function chunk($chunksize)
{
if ($chunksize < 1) {
throw new \InvalidArgumentException("chunksize", $chunksize);
throw new \InvalidArgumentException("'{$chunksize}' is not a valid chunk size.");
}

return Linq::from(new ChunkIterator($this->iterator, $chunksize));
Expand Down
8 changes: 8 additions & 0 deletions tests/Fusonic/Linq/Test/ChunkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ public function testChunk_throwsException_IfchunksizeIsInvalid()
$this->assertException(function () {
Linq::from([])->chunk(-1);
}, self::ExceptionName_InvalidArgument);

$this->assertException(function () {
Linq::from([])->chunk(null);
}, self::ExceptionName_InvalidArgument);

$this->assertException(function () {
Linq::from([])->chunk("");
}, self::ExceptionName_InvalidArgument);
}

public function testChunk_ReturnsChunkedElementsAccordingToChunksize()
Expand Down

0 comments on commit 659b714

Please sign in to comment.