ILIAS  release_7 Revision v7.30-3-g800a261c036
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
8use PHPUnit\Framework\TestCase;
9
10class ArrayEnvironmentTest extends TestCase
11{
15 protected $environment;
16
17 public function setUp() : void
18 {
20 "foo" => "FOO",
21 "bar" => "BAR"
22 ]);
23 }
24
25 public function testGetResource() : void
26 {
27 $this->assertEquals("FOO", $this->environment->getResource("foo"));
28 $this->assertEquals("BAR", $this->environment->getResource("bar"));
29 $this->assertNull($this->environment->getResource("baz"));
30 }
31
32 public function testWithResource() : void
33 {
34 $env = $this->environment->withResource("baz", "BAZ");
35
36 $this->assertEquals("FOO", $env->getResource("foo"));
37 $this->assertEquals("BAR", $env->getResource("bar"));
38 $this->assertEquals("BAZ", $env->getResource("baz"));
39 }
40
41 public function testSetResourceRejectsDuplicates() : void
42 {
43 $this->expectException(\RuntimeException::class);
44
45 $env = $this->environment->withResource("baz", "BAZ");
46 $env->withResource("baz", "BAZ");
47 }
48
49 public function testConfigFor() : void
50 {
51 $env = $this->environment->withConfigFor("foo", "BAR");
52 $this->assertEquals("BAR", $env->getConfigFor("foo"));
53 }
54
55 public function testDuplicateConfigFor() : void
56 {
57 $this->expectException(\RuntimeException::class);
58 $this->environment
59 ->withConfigFor("foo", "BAR")
60 ->withConfigFor("foo", "BAZ")
61 ;
62 }
63
64 public function testWrongConfigId() : void
65 {
66 $this->expectException(\RuntimeException::class);
67 $this->environment->getConfigFor("foofoo");
68 }
69
70 public function testHasConfigFor() : void
71 {
72 $env = $this->environment->withConfigFor("foo", "BAR");
73 $this->assertTrue($env->hasConfigFor("foo"));
74 $this->assertFalse($env->hasConfigFor("bar"));
75 }
76}
An exception for terminatinating execution or to throw for unit testing.
environment()
Definition: environment.php:3
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...