ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
EntryLockingStringMapTest.php
Go to the documentation of this file.
1 <?php
2 
20 
29 
30 require_once './vendor/composer/vendor/autoload.php';
31 
37 #[BackupGlobals(false)]
38 #[BackupStaticProperties(false)]
39 #[PreserveGlobalState(false)]
40 #[RunTestsInSeparateProcesses]
41 class EntryLockingStringMapTest extends TestCase
42 {
47 
51  public function setUp(): void
52  {
53  $this->subject = new EntryLockingStringMap();
54  }
55 
56  #[Test]
57  public function testPutValueWhichShouldSucceed(): void
58  {
59  $key = "hello";
60  $value = "world";
61  $this->subject->put($key, $value);
62  $result = $this->subject->toArray();
63 
64  $this->assertArrayHasKey($key, $result);
65  $this->assertEquals($value, $result[$key]);
66  }
67 
68  #[Test]
69  public function testPutValueTwiceWhichShouldFail(): void
70  {
71  $key = "hello";
72  $value = "world";
73 
74  $this->subject->put($key, $value);
75 
76  $this->expectException(ElementAlreadyExistsException::class);
77  $this->expectExceptionMessage("Element $key can not be overwritten.");
78 
79  $this->subject->put($key, $value);
80  }
81 
82  #[Test]
83  public function testGetWhichShouldSucceed(): void
84  {
85  $key = "hello";
86  $value = "world";
87 
88  $this->subject->put($key, $value);
89  $result = $this->subject->get($key);
90 
91  $this->assertEquals($value, $result);
92  }
93 
94  #[Test]
96  {
97  $key = "hello";
98 
99  $this->expectException(NoSuchElementException::class);
100  $this->expectExceptionMessage("No meta data associated with key \"$key\".");
101  $this->subject->get($key);
102  }
103 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...