-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use iterable instead of \Traversable.
- Loading branch information
Showing
40 changed files
with
244 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\drupol\collection\Iterator; | ||
|
||
use drupol\collection\Iterator\ClosureIterator; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class ClosureIteratorSpec extends ObjectBehavior | ||
{ | ||
public function it_can_be_constructed_with_a_callable_which_is_not_a_generator(): void | ||
{ | ||
$callback = static function () { | ||
return \range(1, 5); | ||
}; | ||
|
||
$this | ||
->beConstructedWith($callback); | ||
} | ||
|
||
public function it_can_get_a_key(): void | ||
{ | ||
$callback = static function () { | ||
return \range(1, 5); | ||
}; | ||
|
||
$this | ||
->beConstructedWith($callback); | ||
|
||
$this | ||
->key() | ||
->shouldReturn(0); | ||
} | ||
|
||
public function it_can_send(): void | ||
{ | ||
$callback = static function () { | ||
yield from \range(1, 5); | ||
}; | ||
|
||
$this | ||
->beConstructedWith($callback); | ||
|
||
$this->send('foo'); | ||
} | ||
|
||
public function it_can_use_next(): void | ||
{ | ||
$callback = static function () { | ||
return \range(1, 5); | ||
}; | ||
|
||
$this | ||
->beConstructedWith($callback); | ||
|
||
$this | ||
->next() | ||
->shouldReturn($this); | ||
|
||
$this | ||
->current() | ||
->shouldReturn(2); | ||
} | ||
|
||
public function it_is_initializable(): void | ||
{ | ||
$callback = static function ($a, $b, $c) { | ||
yield $a; | ||
|
||
yield $b; | ||
|
||
yield $c; | ||
}; | ||
|
||
$this | ||
->beConstructedWith($callback, 'foo', 'bar', 'baz'); | ||
|
||
$this->shouldHaveType(ClosureIterator::class); | ||
|
||
$this | ||
->current() | ||
->shouldBeEqualTo('foo'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.