2019-12-24 01:52:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Psl\Tests\Arr;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2019-12-25 00:35:14 +01:00
|
|
|
use Psl\Arr;
|
2019-12-24 01:52:07 +01:00
|
|
|
|
2019-12-25 00:35:14 +01:00
|
|
|
/**
|
|
|
|
* @covers \Psl\Arr\shuffle
|
|
|
|
*/
|
2019-12-24 01:52:07 +01:00
|
|
|
class ShuffleTest extends TestCase
|
|
|
|
{
|
2019-12-25 00:35:14 +01:00
|
|
|
public function testShuffle(): void
|
|
|
|
{
|
|
|
|
$array = [
|
|
|
|
'foo' => 'bar',
|
|
|
|
'bar' => 'baz',
|
|
|
|
'baz' => 'qux',
|
|
|
|
];
|
|
|
|
|
|
|
|
$shuffled = Arr\shuffle($array);
|
|
|
|
|
|
|
|
static::assertSameSize($shuffled, $array);
|
|
|
|
static::assertNotSame($shuffled, $array);
|
|
|
|
|
|
|
|
foreach ($shuffled as $value) {
|
|
|
|
self::assertTrue(Arr\contains($array, $value));
|
|
|
|
}
|
|
|
|
}
|
2019-12-24 01:52:07 +01:00
|
|
|
}
|