ILIAS  release_7 Revision v7.30-3-g800a261c036
ComponentHelperTest Class Reference
+ Inheritance diagram for ComponentHelperTest:
+ Collaboration diagram for ComponentHelperTest:

Public Member Functions

 setUp ()
 
 test_getCanonicalName ()
 
 test_cachesCanonicalName ()
 
 test_check_arg_ok ()
 @doesNotPerformAssertions More...
 
 test_check_arg_not_ok ()
 
 test_check_int_arg_ok ()
 @doesNotPerformAssertions More...
 
 test_check_int_arg_not_ok ()
 
 test_check_string_arg_ok ()
 @doesNotPerformAssertions More...
 
 test_check_string_arg_not_ok ()
 
 test_check_bool_arg_ok ()
 @doesNotPerformAssertions More...
 
 test_check_bool_arg_not_ok ()
 
 test_check_arg_instanceof_ok ()
 @doesNotPerformAssertions More...
 
 test_check_arg_instanceof_not_ok ()
 
 test_check_arg_is_element_ok ()
 @doesNotPerformAssertions More...
 
 test_check_string_arg_is_element_not_ok ()
 
 test_to_array_with_array ()
 
 test_to_array_with_int ()
 
 test_check_arg_list_elements_ok ()
 @doesNotPerformAssertions More...
 
 test_check_arg_list_elements_no_ok ()
 
 test_check_arg_list_elements_multi_class_ok ()
 @doesNotPerformAssertions More...
 
 test_check_arg_list_elements_multi_class_not_ok ()
 
 test_check_arg_list_elements_string_or_int_ok ()
 @doesNotPerformAssertions More...
 
 test_check_arg_list_elements_string_or_int_not_ok ()
 
 test_check_arg_list_ok ()
 @doesNotPerformAssertions More...
 
 test_check_arg_list_not_ok_1 ()
 
 test_check_arg_list_not_ok_2 ()
 
 test_check_float_arg_ok ()
 @doesNotPerformAssertions More...
 
 test_check_float_arg_not_ok ()
 

Detailed Description

Member Function Documentation

◆ setUp()

ComponentHelperTest::setUp ( )

Definition at line 79 of file ComponentHelperTest.php.

79 : void
80 {
81 $this->mock = new ComponentMock();
82 }

◆ test_cachesCanonicalName()

ComponentHelperTest::test_cachesCanonicalName ( )

Definition at line 90 of file ComponentHelperTest.php.

91 {
92 $name1 = $this->mock->getCanonicalName();
93 $name2 = $this->mock->getCanonicalName();
94 $this->assertEquals($name1, $name2);
95 $this->assertEquals(1, $this->mock->called_gcnbfqn);
96 }

◆ test_check_arg_instanceof_not_ok()

ComponentHelperTest::test_check_arg_instanceof_not_ok ( )

Definition at line 166 of file ComponentHelperTest.php.

167 {
168 $this->expectException(\InvalidArgumentException::class);
169 $this->expectExceptionMessage("Argument 'some_arg': expected ComponentMock, got ComponentHelperTest");
170 $this->mock->_checkArgInstanceOf("some_arg", $this, ComponentMock::class);
171 }

◆ test_check_arg_instanceof_ok()

ComponentHelperTest::test_check_arg_instanceof_ok ( )

@doesNotPerformAssertions

Definition at line 161 of file ComponentHelperTest.php.

162 {
163 $this->mock->_checkArgInstanceOf("some_arg", $this->mock, ComponentMock::class);
164 }

◆ test_check_arg_is_element_ok()

ComponentHelperTest::test_check_arg_is_element_ok ( )

@doesNotPerformAssertions

Definition at line 177 of file ComponentHelperTest.php.

178 {
179 $this->mock->_checkArgIsElement("some_arg", "bar", array("foo", "bar"), "foobar");
180 }

◆ test_check_arg_list_elements_multi_class_not_ok()

ComponentHelperTest::test_check_arg_list_elements_multi_class_not_ok ( )

Definition at line 230 of file ComponentHelperTest.php.

231 {
232 $this->expectException(\InvalidArgumentException::class);
233 $this->expectExceptionMessage("Argument 'some_arg': expected Class1, Class2, got Class3");
234 $l = array(new Class1(), new Class2(), new Class3(), new Class2());
235 $this->mock->_checkArgListElements("some_arg", $l, array("Class1", "Class2"));
236 }

◆ test_check_arg_list_elements_multi_class_ok()

ComponentHelperTest::test_check_arg_list_elements_multi_class_ok ( )

@doesNotPerformAssertions

Definition at line 224 of file ComponentHelperTest.php.

225 {
226 $l = array(new Class1(), new Class2(), new Class1());
227 $this->mock->_checkArgListElements("some_arg", $l, array("Class1", "Class2"));
228 }

◆ test_check_arg_list_elements_no_ok()

ComponentHelperTest::test_check_arg_list_elements_no_ok ( )

Definition at line 213 of file ComponentHelperTest.php.

214 {
215 $this->expectException(\InvalidArgumentException::class);
216 $this->expectExceptionMessage("Argument 'some_arg': expected Class1, got Class2");
217 $l = array(new Class1(), new Class1(), new Class2());
218 $this->mock->_checkArgListElements("some_arg", $l, array("Class1"));
219 }

◆ test_check_arg_list_elements_ok()

ComponentHelperTest::test_check_arg_list_elements_ok ( )

@doesNotPerformAssertions

Definition at line 207 of file ComponentHelperTest.php.

208 {
209 $l = array(new Class1(), new Class1(), new Class1());
210 $this->mock->_checkArgListElements("some_arg", $l, array("Class1"));
211 }

◆ test_check_arg_list_elements_string_or_int_not_ok()

ComponentHelperTest::test_check_arg_list_elements_string_or_int_not_ok ( )

Definition at line 247 of file ComponentHelperTest.php.

248 {
249 $this->expectException(\InvalidArgumentException::class);
250 $this->expectExceptionMessage("Argument 'some_arg': expected string, int, got Class1");
251 $l = array(1, new Class1());
252 $this->mock->_checkArgListElements("some_arg", $l, array("string", "int"));
253 }

◆ test_check_arg_list_elements_string_or_int_ok()

ComponentHelperTest::test_check_arg_list_elements_string_or_int_ok ( )

@doesNotPerformAssertions

Definition at line 241 of file ComponentHelperTest.php.

242 {
243 $l = array(1, "foo");
244 $this->mock->_checkArgListElements("some_arg", $l, array("string", "int"));
245 }

◆ test_check_arg_list_not_ok_1()

ComponentHelperTest::test_check_arg_list_not_ok_1 ( )

Definition at line 268 of file ComponentHelperTest.php.

269 {
270 $m = "expected keys of type string and integer values, got (4 => 3)";
271 $this->expectException(\InvalidArgumentException::class);
272 $this->expectExceptionMessage("Argument 'some_arg': $m");
273 $l = array("a" => 1, "b" => 2, 4 => 3);
274 $this->mock->_checkArgList("some_arg", $l, function ($k, $v) {
275 return is_string($k) && is_int($v);
276 }, function ($k, $v) {
277 return "expected keys of type string and integer values, got ($k => $v)";
278 });
279 }

◆ test_check_arg_list_not_ok_2()

ComponentHelperTest::test_check_arg_list_not_ok_2 ( )

Definition at line 281 of file ComponentHelperTest.php.

282 {
283 $m = "expected keys of type string and integer values, got (c => d)";
284 $this->expectException(\InvalidArgumentException::class);
285 $this->expectExceptionMessage("Argument 'some_arg': $m");
286 $l = array("a" => 1, "b" => 2, "c" => "d");
287 $this->mock->_checkArgList("some_arg", $l, function ($k, $v) {
288 return is_string($k) && is_int($v);
289 }, function ($k, $v) {
290 return "expected keys of type string and integer values, got ($k => $v)";
291 });
292 }

◆ test_check_arg_list_ok()

ComponentHelperTest::test_check_arg_list_ok ( )

@doesNotPerformAssertions

Definition at line 258 of file ComponentHelperTest.php.

259 {
260 $l = array("a" => 1, "b" => 2, "c" => 3);
261 $this->mock->_checkArgList("some_arg", $l, function ($k, $v) {
262 return is_string($k) && is_int($v);
263 }, function ($k, $v) {
264 return "expected keys of type string and integer values, got ($k => $v)";
265 });
266 }

◆ test_check_arg_not_ok()

ComponentHelperTest::test_check_arg_not_ok ( )

Definition at line 106 of file ComponentHelperTest.php.

107 {
108 $this->expectException(\InvalidArgumentException::class);
109 $this->expectExceptionMessage("Argument 'some_arg': some message");
110 $this->mock->_checkArg("some_arg", false, "some message");
111 }

◆ test_check_arg_ok()

ComponentHelperTest::test_check_arg_ok ( )

@doesNotPerformAssertions

Definition at line 101 of file ComponentHelperTest.php.

102 {
103 $this->mock->_checkArg("some_arg", true, "some message");
104 }

◆ test_check_bool_arg_not_ok()

ComponentHelperTest::test_check_bool_arg_not_ok ( )

Definition at line 151 of file ComponentHelperTest.php.

152 {
153 $this->expectException(\InvalidArgumentException::class);
154 $this->expectExceptionMessage("Argument 'some_arg': expected bool, got integer '1'");
155 $this->mock->_checkBoolArg("some_arg", 1);
156 }

◆ test_check_bool_arg_ok()

ComponentHelperTest::test_check_bool_arg_ok ( )

@doesNotPerformAssertions

Definition at line 146 of file ComponentHelperTest.php.

147 {
148 $this->mock->_checkBoolArg("some_arg", true);
149 }

◆ test_check_float_arg_not_ok()

ComponentHelperTest::test_check_float_arg_not_ok ( )

Definition at line 302 of file ComponentHelperTest.php.

303 {
304 $this->expectException(\InvalidArgumentException::class);
305 $this->expectExceptionMessage("Argument 'some_arg': expected float, got string 'foo'");
306 $this->mock->_checkFloatArg("some_arg", "foo");
307 }

◆ test_check_float_arg_ok()

ComponentHelperTest::test_check_float_arg_ok ( )

@doesNotPerformAssertions

Definition at line 297 of file ComponentHelperTest.php.

298 {
299 $this->mock->_checkFloatArg("some_arg", 1.73);
300 }

◆ test_check_int_arg_not_ok()

ComponentHelperTest::test_check_int_arg_not_ok ( )

Definition at line 121 of file ComponentHelperTest.php.

122 {
123 $this->expectException(\InvalidArgumentException::class);
124 $this->expectExceptionMessage("Argument 'some_arg': expected integer, got string 'foo'");
125 $this->mock->_checkIntArg("some_arg", "foo");
126 }

◆ test_check_int_arg_ok()

ComponentHelperTest::test_check_int_arg_ok ( )

@doesNotPerformAssertions

Definition at line 116 of file ComponentHelperTest.php.

117 {
118 $this->mock->_checkIntArg("some_arg", 1);
119 }

◆ test_check_string_arg_is_element_not_ok()

ComponentHelperTest::test_check_string_arg_is_element_not_ok ( )

Definition at line 182 of file ComponentHelperTest.php.

183 {
184 $this->expectException(\InvalidArgumentException::class);
185 $this->expectExceptionMessage("Argument 'some_arg': expected foobar, got 'baz'");
186 $this->mock->_checkArgIsElement("some_arg", "baz", array("foo", "bar"), "foobar");
187 }

◆ test_check_string_arg_not_ok()

ComponentHelperTest::test_check_string_arg_not_ok ( )

Definition at line 136 of file ComponentHelperTest.php.

137 {
138 $this->expectException(\InvalidArgumentException::class);
139 $this->expectExceptionMessage("Argument 'some_arg': expected string, got integer '1'");
140 $this->mock->_checkStringArg("some_arg", 1);
141 }

◆ test_check_string_arg_ok()

ComponentHelperTest::test_check_string_arg_ok ( )

@doesNotPerformAssertions

Definition at line 131 of file ComponentHelperTest.php.

132 {
133 $this->mock->_checkStringArg("some_arg", "bar");
134 }

◆ test_getCanonicalName()

ComponentHelperTest::test_getCanonicalName ( )

Definition at line 84 of file ComponentHelperTest.php.

85 {
86 $c = new \ILIAS\UI\Component\Test\TestComponent("foo");
87 $this->assertEquals("Test Component Test", $c->getCanonicalName());
88 }
$c
Definition: cli.php:37

References $c.

◆ test_to_array_with_array()

ComponentHelperTest::test_to_array_with_array ( )

Definition at line 189 of file ComponentHelperTest.php.

190 {
191 $foo = array("foo", "bar");
192 $res = $this->mock->_toArray($foo);
193
194 $this->assertEquals($foo, $res);
195 }
foreach($_POST as $key=> $value) $res

References Vendor\Package\$foo, and $res.

◆ test_to_array_with_int()

ComponentHelperTest::test_to_array_with_int ( )

Definition at line 197 of file ComponentHelperTest.php.

198 {
199 $foo = 1;
200 $res = $this->mock->_toArray($foo);
201 $this->assertEquals(array($foo), $res);
202 }

References Vendor\Package\$foo, and $res.


The documentation for this class was generated from the following file: