mirror of
https://github.com/danog/endtoend-test-psl.git
synced 2024-12-12 17:17:25 +01:00
49 lines
1008 B
PHP
49 lines
1008 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Psl\Tests\Arr;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Psl\Arr;
|
|
|
|
class SortTest extends TestCase
|
|
{
|
|
/**
|
|
* @dataProvider provideData
|
|
*/
|
|
public function testSort(array $expected, array $array, ?callable $comparator = null): void
|
|
{
|
|
static::assertSame($expected, Arr\sort($array, $comparator));
|
|
}
|
|
|
|
public function provideData(): array
|
|
{
|
|
return [
|
|
[
|
|
['a', 'b', 'c'],
|
|
['c', 'a', 'b'],
|
|
],
|
|
|
|
[
|
|
[8, 9, 10],
|
|
[8, 9, 10],
|
|
/**
|
|
* @param int $a
|
|
* @param int $b
|
|
*
|
|
* @return int
|
|
*
|
|
* @psalm-pure
|
|
*/
|
|
fn (int $a, int $b) => $a <=> $b ? -1 : 1,
|
|
],
|
|
|
|
[
|
|
['bar', 'baz'],
|
|
['foo' => 'bar', 'bar' => 'baz'],
|
|
],
|
|
];
|
|
}
|
|
}
|