Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add coverage check #142

Merged
merged 2 commits into from Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Expand Up @@ -50,7 +50,7 @@ jobs:
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Run Grumphp
run: vendor/bin/grumphp run --tasks=phpspec
run: vendor/bin/grumphp run --tasks=phpspec,coverage_clover

- name: Send Scrutinizer data
run: |
Expand Down
3 changes: 3 additions & 0 deletions grumphp.yml
Expand Up @@ -53,6 +53,9 @@ parameters:
extra_tasks:
phpspec:
verbose: true
clover_coverage:
clover_file: build/logs/clover.xml
level: 99
infection:
threads: 10
test_framework: phpspec
Expand Down
8 changes: 2 additions & 6 deletions spec/loophp/collection/CollectionSpec.php
Expand Up @@ -2069,7 +2069,8 @@ public function it_can_matching(): void

$criteria = Criteria::create()
->andWhere(Criteria::expr()->eq('is_admin', true))
->orderBy(['age' => 'ASC']);
->orderBy(['age' => 'ASC'])
->setMaxResults(1);

$this::fromIterable($users)
->matching($criteria)
Expand All @@ -2080,11 +2081,6 @@ public function it_can_matching(): void
'age' => 7,
'is_admin' => true,
],
0 => [
'name' => 'Pol',
'age' => 39,
'is_admin' => true,
],
]
);
}
Expand Down
@@ -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);
}
}
44 changes: 44 additions & 0 deletions spec/loophp/collection/Iterator/StringIteratorSpec.php
@@ -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);
}
}
8 changes: 4 additions & 4 deletions src/Iterator/MultipleIterableIterator.php
Expand Up @@ -23,14 +23,14 @@
final class MultipleIterableIterator extends ProxyIterator
{
/**
* @param iterable<TKey, T> $iterators
* @param iterable<TKey, T> $iterables
*/
public function __construct(iterable ...$iterators)
public function __construct(iterable ...$iterables)
{
$appendIterator = new AppendIterator();

foreach ($iterators as $iterator) {
$appendIterator->append(new NoRewindIterator(new IterableIterator($iterator)));
foreach ($iterables as $iterable) {
$appendIterator->append(new NoRewindIterator(new IterableIterator($iterable)));
}

$this->iterator = $appendIterator;
Expand Down