-
-
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.
- Loading branch information
Showing
3 changed files
with
144 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\loophp\collection\Operation; | ||
|
||
use ArrayIterator; | ||
use loophp\collection\Operation\Current; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class CurrentSpec extends ObjectBehavior | ||
{ | ||
public function it_can_get_current() | ||
{ | ||
$input = range('a', 'e'); | ||
|
||
$iterator = new ArrayIterator($input); | ||
|
||
$this | ||
->__invoke()(0)($iterator) | ||
->current() | ||
->shouldReturn('a'); | ||
|
||
$this | ||
->__invoke()(0)($iterator) | ||
->shouldHaveCount(1); | ||
} | ||
|
||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(Current::class); | ||
} | ||
} |
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,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\loophp\collection\Operation; | ||
|
||
use ArrayIterator; | ||
use loophp\collection\Operation\Limit; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class LimitSpec extends ObjectBehavior | ||
{ | ||
public function it_can_set_a_limit() | ||
{ | ||
$input = range('a', 'e'); | ||
|
||
$iterator = new ArrayIterator($input); | ||
|
||
$this | ||
->__invoke()(1)(0)($iterator) | ||
->shouldHaveCount(1); | ||
|
||
$this | ||
->__invoke()(2)(0)($iterator) | ||
->shouldHaveCount(2); | ||
} | ||
|
||
public function it_can_set_an_offset() | ||
{ | ||
$input = range('a', 'e'); | ||
|
||
$iterator = new ArrayIterator($input); | ||
|
||
$this | ||
->__invoke()(1)(2)($iterator) | ||
->current() | ||
->shouldReturn('c'); | ||
|
||
$this | ||
->__invoke()(2)(2)($iterator) | ||
->shouldHaveCount(2); | ||
} | ||
|
||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(Limit::class); | ||
} | ||
} |