ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
EntryLockingStringMapTest.php
Go to the documentation of this file.
1<?php
2
4
7
8require_once './libs/composer/vendor/autoload.php';
9
21{
22
26 private $subject;
27
31 public function setUp()
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->setExpectedException(ElementAlreadyExistsException::class, "Element $key can not be overwritten.");
61
62 $this->subject->put($key, $value);
63 }
64
68 public function testGetWhichShouldSucceed()
69 {
70 $key = "hello";
71 $value = "world";
72
73 $this->subject->put($key, $value);
74 $result = $this->subject->get($key);
75
76 $this->assertEquals($value, $result);
77 }
78
83 {
84 $key = "hello";
85
86 $this->setExpectedException(NoSuchElementException::class, "No meta data associated with key \"$key\".");
87 $this->subject->get($key);
88 }
89}
$result
An exception for terminatinating execution or to throw for unit testing.
$key
Definition: croninfo.php:18