Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add coverage check * Add to workflow and add tests
- Loading branch information
1 parent
2ea1fe6
commit e11bcf2
Showing
6 changed files
with
114 additions
and
11 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
60 changes: 60 additions & 0 deletions
60
spec/loophp/collection/Iterator/MultipleIterableIteratorSpec.php
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,60 @@ | ||
<?php | ||
|
||
/** | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\loophp\collection\Iterator; | ||
|
||
use ArrayIterator; | ||
use Generator; | ||
use loophp\collection\Iterator\MultipleIterableIterator; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class MultipleIterableIteratorSpec extends ObjectBehavior | ||
{ | ||
public function it_can_iterate_with_a_single_iterable(): void | ||
{ | ||
$this->beConstructedWith([1, 2, 3]); | ||
|
||
$this->getInnerIterator()->shouldIterateAs([1, 2, 3]); | ||
} | ||
|
||
public function it_can_iterate_with_multiple_iterables(): void | ||
{ | ||
$this->beConstructedWith([1, 2, 3], new ArrayIterator([4, 5, 6])); | ||
|
||
$expected = static function (): Generator { | ||
yield 0 => 1; | ||
|
||
yield 1 => 2; | ||
|
||
yield 2 => 3; | ||
|
||
yield 0 => 4; | ||
|
||
yield 1 => 5; | ||
|
||
yield 2 => 6; | ||
}; | ||
|
||
$this->getInnerIterator()->shouldIterateAs($expected()); | ||
} | ||
|
||
public function it_is_initializable_with_a_single_iterable(): void | ||
{ | ||
$this->beConstructedWith([1, 2, 3]); | ||
|
||
$this->shouldHaveType(MultipleIterableIterator::class); | ||
} | ||
|
||
public function it_is_initializable_with_multiple_iterables(): void | ||
{ | ||
$this->beConstructedWith([1, 2, 3], new ArrayIterator([4, 5, 6])); | ||
|
||
$this->shouldHaveType(MultipleIterableIterator::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,44 @@ | ||
<?php | ||
|
||
/** | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\loophp\collection\Iterator; | ||
|
||
use loophp\collection\Iterator\StringIterator; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class StringIteratorSpec extends ObjectBehavior | ||
{ | ||
public function it_can_iterate_with_default_delimiter(): void | ||
{ | ||
$this->beConstructedWith('A string.'); | ||
|
||
$this->getInnerIterator()->shouldIterateAs(['A', ' ', 's', 't', 'r', 'i', 'n', 'g', '.']); | ||
} | ||
|
||
public function it_can_iterate_with_given_delimiter(): void | ||
{ | ||
$this->beConstructedWith('I am a string.', ' '); | ||
|
||
$this->getInnerIterator()->shouldIterateAs(['I', 'am', 'a', 'string.']); | ||
} | ||
|
||
public function it_is_initializable_with_default_delimiter(): void | ||
{ | ||
$this->beConstructedWith('I am a string.'); | ||
|
||
$this->shouldHaveType(StringIterator::class); | ||
} | ||
|
||
public function it_is_initializable_with_given_delimiter(): void | ||
{ | ||
$this->beConstructedWith('I am a string.', ' '); | ||
|
||
$this->shouldHaveType(StringIterator::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