ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ArrayEnvironmentTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Tests\Setup;
22 
23 use ILIAS\Setup;
25 
26 class ArrayEnvironmentTest extends TestCase
27 {
29 
30  public function setUp(): void
31  {
32  $this->environment = new Setup\ArrayEnvironment([
33  "foo" => "FOO",
34  "bar" => "BAR"
35  ]);
36  }
37 
38  public function testGetResource(): void
39  {
40  $this->assertEquals("FOO", $this->environment->getResource("foo"));
41  $this->assertEquals("BAR", $this->environment->getResource("bar"));
42  $this->assertNull($this->environment->getResource("baz"));
43  }
44 
45  public function testWithResource(): void
46  {
47  $env = $this->environment->withResource("baz", "BAZ");
48 
49  $this->assertEquals("FOO", $env->getResource("foo"));
50  $this->assertEquals("BAR", $env->getResource("bar"));
51  $this->assertEquals("BAZ", $env->getResource("baz"));
52  }
53 
54  public function testSetResourceRejectsDuplicates(): void
55  {
56  $this->expectException(\RuntimeException::class);
57 
58  $env = $this->environment->withResource("baz", "BAZ");
59  $env->withResource("baz", "BAZ");
60  }
61 
62  public function testConfigFor(): void
63  {
64  $env = $this->environment->withConfigFor("foo", "BAR");
65  $this->assertEquals("BAR", $env->getConfigFor("foo"));
66  }
67 
68  public function testDuplicateConfigFor(): void
69  {
70  $this->expectException(\RuntimeException::class);
71  $this->environment
72  ->withConfigFor("foo", "BAR")
73  ->withConfigFor("foo", "BAZ")
74  ;
75  }
76 
77  public function testWrongConfigId(): void
78  {
79  $this->expectException(\RuntimeException::class);
80  $this->environment->getConfigFor("foofoo");
81  }
82 
83  public function testHasConfigFor(): void
84  {
85  $env = $this->environment->withConfigFor("foo", "BAR");
86  $this->assertTrue($env->hasConfigFor("foo"));
87  $this->assertFalse($env->hasConfigFor("bar"));
88  }
89 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...