64 lines
2.1 KiB
PHP
64 lines
2.1 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
/*
|
|
* Copyright (c) 2020 https://rewiv.com sikofitt@gmail.com
|
|
*
|
|
* This file is a part of Olive BBS
|
|
*
|
|
* This Source Code Form is subject to the
|
|
* terms of the Mozilla Public License, v. 2.0.
|
|
*
|
|
* If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*
|
|
* ___ ___ ___
|
|
* ( ).-. ( ) ( )
|
|
* .--. | |( __)___ ___ .--. | |.-. | |.-. .--.
|
|
* / \| |(''"( )( / \| / \| / \ / _ \
|
|
* | .-. | | | | | | | | .-. | .-. | .-. |. .' `. ;
|
|
* | | | | | | | | | | | | | | | | | | | || ' | |
|
|
* | | | | | | | | | | | |/ | | | | | | |_\_`.(___)
|
|
* | | | | | | | | | | | ' _.| | | | | | ( ). '.
|
|
* | ' | | | | | ' ' ; | .'.-| ' | | ' | || | `\ |
|
|
* ' `-' | | | | \ `' /' `-' ' `-' ;' `-' ; ; '._,' '
|
|
* `.__.(___(___) '_.' `.__.' `.__. `.__. '.___.'
|
|
*
|
|
*/
|
|
|
|
namespace Olivebbs\Tests\Map;
|
|
|
|
use Olivebbs\Map\Exception\ImmutableMapException;
|
|
use Olivebbs\Map\Exception\InvalidArgumentException;
|
|
use Olivebbs\Map\GenericMap;
|
|
use Olivebbs\Map\ImmutableMap;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ImmutableMapTest extends TestCase
|
|
{
|
|
public function testOffsetUnset(): void
|
|
{
|
|
$immutableMap = ImmutableMap::create(GenericMap::INTEGER, GenericMap::CHAR, range('A', 'Z'));
|
|
$this->expectException(ImmutableMapException::class);
|
|
unset($immutableMap[0]);
|
|
}
|
|
|
|
public function testOffsetSet(): void
|
|
{
|
|
$immutableMap = ImmutableMap::create(GenericMap::INTEGER, GenericMap::CHAR, range('A', 'Z'));
|
|
$this->expectException(ImmutableMapException::class);
|
|
$immutableMap[0] = 1;
|
|
}
|
|
|
|
public function test__construct(): void
|
|
{
|
|
$values = [
|
|
'A' => 1,
|
|
'C' => 2,
|
|
'3' => 4,
|
|
];
|
|
$this->expectException(InvalidArgumentException::class);
|
|
$this->expectExceptionMessage('Invalid types for map [string => int], they should be [int => string]');
|
|
$immutableMap = ImmutableMap::create(GenericMap::INT, GenericMap::STRING, $values);
|
|
}
|
|
}
|