ILIAS  release_8 Revision v8.24
EntryLockingStringMapTest.php
Go to the documentation of this file.
1<?php
2
4
7use PHPUnit\Framework\TestCase;
8
9require_once './libs/composer/vendor/autoload.php';
10
21class EntryLockingStringMapTest extends TestCase
22{
26 private $subject;
27
31 public function setUp(): void
32 {
33 $this->subject = new EntryLockingStringMap();
34 }
35
40 {
41 $key = "hello";
42 $value = "world";
43 $this->subject->put($key, $value);
44 $result = $this->subject->toArray();
45
46 $this->assertArrayHasKey($key, $result);
47 $this->assertEquals($value, $result[$key]);
48 }
49
54 {
55 $key = "hello";
56 $value = "world";
57
58 $this->subject->put($key, $value);
59
60 $this->expectException(ElementAlreadyExistsException::class);
61 $this->expectExceptionMessage("Element $key can not be overwritten.");
62
63 $this->subject->put($key, $value);
64 }
65
69 public function testGetWhichShouldSucceed()
70 {
71 $key = "hello";
72 $value = "world";
73
74 $this->subject->put($key, $value);
75 $result = $this->subject->get($key);
76
77 $this->assertEquals($value, $result);
78 }
79
84 {
85 $key = "hello";
86
87 $this->expectException(NoSuchElementException::class);
88 $this->expectExceptionMessage("No meta data associated with key \"$key\".");
89 $this->subject->get($key);
90 }
91}
string $key
Consumer key/client ID value.
Definition: System.php:193