ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ArrayEnvironmentTest.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2019 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
5namespace ILIAS\Tests\Setup;
6
8
9class ArrayEnvironmentTest extends \PHPUnit\Framework\TestCase
10{
11 public function setUp() : void
12 {
14 "foo" => "FOO",
15 "bar" => "BAR"
16 ]);
17 }
18
19 public function testGetResource()
20 {
21 $this->assertEquals("FOO", $this->environment->getResource("foo"));
22 $this->assertEquals("BAR", $this->environment->getResource("bar"));
23 $this->assertNull($this->environment->getResource("baz"));
24 }
25
26 public function testWithResource()
27 {
28 $env = $this->environment->withResource("baz", "BAZ");
29
30 $this->assertEquals("FOO", $env->getResource("foo"));
31 $this->assertEquals("BAR", $env->getResource("bar"));
32 $this->assertEquals("BAZ", $env->getResource("baz"));
33 }
34
36 {
37 $this->expectException(\RuntimeException::class);
38
39 $env = $this->environment->withResource("baz", "BAZ");
40 $env->withResource("baz", "BAZ");
41 }
42
43 public function testConfigFor()
44 {
45 $env = $this->environment->withConfigFor("foo", "BAR");
46 $this->assertEquals("BAR", $env->getConfigFor("foo"));
47 }
48
49 public function testDuplicateConfigFor()
50 {
51 $this->expectException(\RuntimeException::class);
52 $env = $this->environment
53 ->withConfigFor("foo", "BAR")
54 ->withConfigFor("foo", "BAZ");
55 }
56
57 public function testWrongConfigId()
58 {
59 $this->expectException(\RuntimeException::class);
60 $env = $this->environment
61 ->getConfigFor("foofoo");
62 }
63}
An exception for terminatinating execution or to throw for unit testing.
environment()
Definition: environment.php:3