Skip to content

Commit

Permalink
Skip some tests on PHP 7
Browse files Browse the repository at this point in the history
  • Loading branch information
sanmai committed Nov 7, 2022
1 parent bc7e7ca commit 2981eba
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/AppendPrependTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use function count;
use function is_numeric;
use function key;
use const PHP_VERSION_ID;
use PHPUnit\Framework\TestCase;
use function Pipeline\take;

Expand Down Expand Up @@ -75,13 +76,17 @@ public function provideAppendArrays(): iterable
*/
public function testPush(array $expected, ?array $initialValue, ...$iterables): void
{
$useKeys = !is_numeric(key($expected));
if ($useKeys && PHP_VERSION_ID < 80000) {
$this->markTestIncomplete('PHP 7 fails with an error: Cannot unpack array with string keys');
}

$pipeline = take($initialValue);

foreach ($iterables as $iterable) {
$pipeline->push(...$iterable ?? []);
}

$useKeys = !is_numeric(key($expected));
$this->assertSame($expected, $pipeline->toArray($useKeys));
}

Expand Down Expand Up @@ -133,13 +138,17 @@ public function providePrependArrays(): iterable
*/
public function testUnshift(array $expected, ?array $initialValue, ...$iterables): void
{
$useKeys = !is_numeric(key($expected));
if ($useKeys && PHP_VERSION_ID < 80000) {
$this->markTestIncomplete('PHP 7 fails with an error: Cannot unpack array with string keys');
}

$pipeline = take($initialValue);

foreach ($iterables as $iterable) {
$pipeline->unshift(...$iterable ?? []);
}

$useKeys = !is_numeric(key($expected));
$this->assertSame($expected, $pipeline->toArray($useKeys));
}

Expand Down

0 comments on commit 2981eba

Please sign in to comment.