mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-30 00:47:48 +00:00
37 lines
772 B
PHP
37 lines
772 B
PHP
|
<?php
|
||
|
/**
|
||
|
* MadLisp language
|
||
|
* @link http://madlisp.com/
|
||
|
* @copyright Copyright (c) 2020 Pekka Laiho
|
||
|
*/
|
||
|
|
||
|
use PHPUnit\Framework\TestCase;
|
||
|
|
||
|
use MadLisp\Hash;
|
||
|
use MadLisp\MadLispException;
|
||
|
|
||
|
class HashTest extends TestCase
|
||
|
{
|
||
|
public function testHash()
|
||
|
{
|
||
|
$hash = new Hash(['a' => 1]);
|
||
|
$hash->set('b', 2);
|
||
|
|
||
|
$this->assertSame(1, $hash->get('a'));
|
||
|
$this->assertSame(2, $hash->get('b'));
|
||
|
|
||
|
$this->assertSame(2, $hash->unset('b'));
|
||
|
|
||
|
$this->assertSame(['a' => 1], $hash->getData());
|
||
|
}
|
||
|
|
||
|
public function testNotFound()
|
||
|
{
|
||
|
$this->expectException(MadLispException::class);
|
||
|
$this->expectExceptionMessage('hash does not contain key abc');
|
||
|
|
||
|
$hash = new Hash();
|
||
|
$hash->get('abc');
|
||
|
}
|
||
|
}
|