<?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\Enum\KeyType; use Olivebbs\Map\Enum\ValueType; use Olivebbs\Map\Exception\ImmutableMapException; use Olivebbs\Map\Exception\InvalidArgumentException; use Olivebbs\Map\ImmutableMap; use PHPUnit\Framework\TestCase; class ImmutableMapTest extends TestCase { public function testOffsetUnset(): void { $immutableMap = ImmutableMap::create(KeyType::INTEGER, ValueType::CHAR, range('A', 'Z')); $this->expectException(ImmutableMapException::class); unset($immutableMap[0]); } public function testOffsetSet(): void { $immutableMap = ImmutableMap::create(KeyType::INTEGER, ValueType::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(KeyType::INT, ValueType::STRING, $values); } }