mirror of
https://github.com/danog/endtoend-test-psl.git
synced 2024-12-02 17:56:09 +01:00
40 lines
826 B
PHP
40 lines
826 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Psl\Tests\Dict;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Psl\Collection;
|
|
use Psl\Dict;
|
|
use Psl\Iter;
|
|
use Psl\Vec;
|
|
|
|
final class UniqueTest extends TestCase
|
|
{
|
|
public function testUnique(): void
|
|
{
|
|
$array = Vec\fill(10, 'foo');
|
|
|
|
$unique = Dict\unique($array);
|
|
|
|
static::assertCount(1, $unique);
|
|
|
|
static::assertSame('foo', Iter\first($unique));
|
|
}
|
|
|
|
public function testUniqueWithObjects(): void
|
|
{
|
|
$array = Vec\fill(10, 'foo');
|
|
$object = new Collection\Map([]);
|
|
$array = Vec\concat($array, Vec\fill(10, $object));
|
|
|
|
$unique = Dict\unique($array);
|
|
|
|
static::assertCount(2, $unique);
|
|
|
|
static::assertSame('foo', Iter\first($unique));
|
|
static::assertSame($object, Iter\last($unique));
|
|
}
|
|
}
|