mirror of
https://github.com/danog/endtoend-test-psl.git
synced 2024-12-02 09:38:32 +01:00
43 lines
1.0 KiB
PHP
43 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Psl\Tests\Dict;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Psl;
|
|
use Psl\Dict;
|
|
|
|
final class AssociateTest extends TestCase
|
|
{
|
|
public function testAssociate(): void
|
|
{
|
|
static::assertSame(['a' => 1, 'b' => 2, 'c' => 3], Dict\associate(
|
|
['a', 'b', 'c'],
|
|
[1, 2, 3]
|
|
));
|
|
}
|
|
|
|
public function testAssociateWithMissingKeys(): void
|
|
{
|
|
$this->expectException(Psl\Exception\InvariantViolationException::class);
|
|
$this->expectExceptionMessage('Expected length of $keys and $values to be the same');
|
|
|
|
Dict\associate(
|
|
['a', 'b', 'c'],
|
|
[1, 2, 3, 4]
|
|
);
|
|
}
|
|
|
|
public function testAssociateWithMissingValues(): void
|
|
{
|
|
$this->expectException(Psl\Exception\InvariantViolationException::class);
|
|
$this->expectExceptionMessage('Expected length of $keys and $values to be the same');
|
|
|
|
Dict\associate(
|
|
['a', 'b', 'c', 'd', 'e', 'f'],
|
|
[1, 2, 3, 4]
|
|
);
|
|
}
|
|
}
|