ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilSettingTest.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24use PHPUnit\Framework\TestCase;
25
30class ilSettingTest extends TestCase
31{
32 protected $backupGlobals = false;
33
34 protected function setUp() : void
35 {
36 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
37 ilUnitUtil::performInitialisation();
38 }
39
43 public function testSetGetSettings()
44 {
45 $set = new ilSetting("test_module");
46 $set->set("foo", "bar");
47 $value = $set->get("foo");
48
49 $this->assertEquals("bar", $value);
50 }
51
55 public function testDeletion()
56 {
57 // set two things for two modules
58 $set = new ilSetting("test_module");
59 $set->set("foo", "bar");
60 $set = new ilSetting("test_module2");
61 $set->set("foo2", "bar2");
62 $set = new ilSetting("test_module");
63 $set->deleteAll();
64
65 $value = $set->get("foo", false, true) . "-"; // should be "-" now
66
67 $set = new ilSetting("test_module2");
68 $value .= $set->get("foo2"); // should be "-bar2" now
69
70 $this->assertEquals("-bar2", $value);
71 }
72
76 public function testLikeDeletion()
77 {
78 $set = new ilSetting("test_module3");
79 $set->set("foo", "plus");
80 $set->set("fooplus", "bar");
81 $set->set("barplus", "foo");
82 $set->deleteLike("foo%");
83
84 $value = $set->get("foo") . "-" .
85 $set->get("fooplus") . "-" .
86 $set->get("barplus");
87
88 $this->assertEquals("--foo", $value);
89 }
90}
An exception for terminatinating execution or to throw for unit testing.
Class ilSettingTest @group needsInstalledILIAS.
testSetGetSettings()
@group IL_Init
testLikeDeletion()
@group IL_Init
testDeletion()
@group IL_Init
ILIAS Setting Class.