ILIAS  release_8 Revision v8.24
ComponentHelperTest Class Reference
+ Inheritance diagram for ComponentHelperTest:
+ Collaboration diagram for ComponentHelperTest:

Public Member Functions

 setUp ()
 
 test_getCanonicalName ()
 
 test_check_arg_ok ()
 @doesNotPerformAssertions More...
 
 test_check_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 ()
 

Protected Attributes

ComponentMock $mock
 

Detailed Description

Member Function Documentation

◆ setUp()

ComponentHelperTest::setUp ( )

Definition at line 93 of file ComponentHelperTest.php.

93 : void
94 {
95 $this->mock = new ComponentMock();
96 }

◆ test_check_arg_instanceof_not_ok()

ComponentHelperTest::test_check_arg_instanceof_not_ok ( )

Definition at line 157 of file ComponentHelperTest.php.

157 : void
158 {
159 $this->expectException(InvalidArgumentException::class);
160 $this->expectExceptionMessage("Argument 'some_arg': expected ComponentMock, got ComponentHelperTest");
161 $this->mock->_checkArgInstanceOf("some_arg", $this, ComponentMock::class);
162 }

◆ test_check_arg_instanceof_ok()

ComponentHelperTest::test_check_arg_instanceof_ok ( )

@doesNotPerformAssertions

Definition at line 152 of file ComponentHelperTest.php.

152 : void
153 {
154 $this->mock->_checkArgInstanceOf("some_arg", $this->mock, ComponentMock::class);
155 }

◆ test_check_arg_is_element_ok()

ComponentHelperTest::test_check_arg_is_element_ok ( )

@doesNotPerformAssertions

Definition at line 168 of file ComponentHelperTest.php.

168 : void
169 {
170 $this->mock->_checkArgIsElement("some_arg", "bar", array("foo", "bar"), "foobar");
171 }

◆ test_check_arg_list_elements_multi_class_not_ok()

ComponentHelperTest::test_check_arg_list_elements_multi_class_not_ok ( )

Definition at line 221 of file ComponentHelperTest.php.

221 : void
222 {
223 $this->expectException(InvalidArgumentException::class);
224 $this->expectExceptionMessage("Argument 'some_arg': expected Class1, Class2, got Class3");
225 $l = array(new Class1(), new Class2(), new Class3(), new Class2());
226 $this->mock->_checkArgListElements("some_arg", $l, array("Class1", "Class2"));
227 }

◆ test_check_arg_list_elements_multi_class_ok()

ComponentHelperTest::test_check_arg_list_elements_multi_class_ok ( )

@doesNotPerformAssertions

Definition at line 215 of file ComponentHelperTest.php.

215 : void
216 {
217 $l = array(new Class1(), new Class2(), new Class1());
218 $this->mock->_checkArgListElements("some_arg", $l, array("Class1", "Class2"));
219 }

◆ test_check_arg_list_elements_no_ok()

ComponentHelperTest::test_check_arg_list_elements_no_ok ( )

Definition at line 204 of file ComponentHelperTest.php.

204 : void
205 {
206 $this->expectException(InvalidArgumentException::class);
207 $this->expectExceptionMessage("Argument 'some_arg': expected Class1, got Class2");
208 $l = array(new Class1(), new Class1(), new Class2());
209 $this->mock->_checkArgListElements("some_arg", $l, array("Class1"));
210 }

◆ test_check_arg_list_elements_ok()

ComponentHelperTest::test_check_arg_list_elements_ok ( )

@doesNotPerformAssertions

Definition at line 198 of file ComponentHelperTest.php.

198 : void
199 {
200 $l = array(new Class1(), new Class1(), new Class1());
201 $this->mock->_checkArgListElements("some_arg", $l, array("Class1"));
202 }

◆ test_check_arg_list_elements_string_or_int_not_ok()

ComponentHelperTest::test_check_arg_list_elements_string_or_int_not_ok ( )

Definition at line 238 of file ComponentHelperTest.php.

238 : void
239 {
240 $this->expectException(InvalidArgumentException::class);
241 $this->expectExceptionMessage("Argument 'some_arg': expected string, int, got Class1");
242 $l = array(1, new Class1());
243 $this->mock->_checkArgListElements("some_arg", $l, array("string", "int"));
244 }

◆ test_check_arg_list_elements_string_or_int_ok()

ComponentHelperTest::test_check_arg_list_elements_string_or_int_ok ( )

@doesNotPerformAssertions

Definition at line 232 of file ComponentHelperTest.php.

232 : void
233 {
234 $l = array(1, "foo");
235 $this->mock->_checkArgListElements("some_arg", $l, array("string", "int"));
236 }

◆ test_check_arg_list_not_ok_1()

ComponentHelperTest::test_check_arg_list_not_ok_1 ( )

Definition at line 259 of file ComponentHelperTest.php.

259 : void
260 {
261 $m = "expected keys of type string and integer values, got (4 => 3)";
262 $this->expectException(InvalidArgumentException::class);
263 $this->expectExceptionMessage("Argument 'some_arg': $m");
264 $l = array("a" => 1, "b" => 2, 4 => 3);
265 $this->mock->_checkArgList("some_arg", $l, function ($k, $v) {
266 return is_string($k) && is_int($v);
267 }, function ($k, $v) {
268 return "expected keys of type string and integer values, got ($k => $v)";
269 });
270 }

◆ test_check_arg_list_not_ok_2()

ComponentHelperTest::test_check_arg_list_not_ok_2 ( )

Definition at line 272 of file ComponentHelperTest.php.

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

◆ test_check_arg_list_ok()

ComponentHelperTest::test_check_arg_list_ok ( )

@doesNotPerformAssertions

Definition at line 249 of file ComponentHelperTest.php.

249 : void
250 {
251 $l = array("a" => 1, "b" => 2, "c" => 3);
252 $this->mock->_checkArgList("some_arg", $l, function ($k, $v) {
253 return is_string($k) && is_int($v);
254 }, function ($k, $v) {
255 return "expected keys of type string and integer values, got ($k => $v)";
256 });
257 }

◆ test_check_arg_not_ok()

ComponentHelperTest::test_check_arg_not_ok ( )

Definition at line 112 of file ComponentHelperTest.php.

112 : void
113 {
114 $this->expectException(InvalidArgumentException::class);
115 $this->expectExceptionMessage("Argument 'some_arg': some message");
116 $this->mock->_checkArg("some_arg", false, "some message");
117 }

◆ test_check_arg_ok()

ComponentHelperTest::test_check_arg_ok ( )

@doesNotPerformAssertions

Definition at line 107 of file ComponentHelperTest.php.

107 : void
108 {
109 $this->mock->_checkArg("some_arg", true, "some message");
110 }

◆ test_check_bool_arg_not_ok()

ComponentHelperTest::test_check_bool_arg_not_ok ( )

Definition at line 142 of file ComponentHelperTest.php.

142 : void
143 {
144 $this->expectException(InvalidArgumentException::class);
145 $this->expectExceptionMessage("Argument 'some_arg': expected bool, got integer '1'");
146 $this->mock->_checkBoolArg("some_arg", 1);
147 }

◆ test_check_bool_arg_ok()

ComponentHelperTest::test_check_bool_arg_ok ( )

@doesNotPerformAssertions

Definition at line 137 of file ComponentHelperTest.php.

137 : void
138 {
139 $this->mock->_checkBoolArg("some_arg", true);
140 }

◆ test_check_string_arg_is_element_not_ok()

ComponentHelperTest::test_check_string_arg_is_element_not_ok ( )

Definition at line 173 of file ComponentHelperTest.php.

173 : void
174 {
175 $this->expectException(InvalidArgumentException::class);
176 $this->expectExceptionMessage("Argument 'some_arg': expected foobar, got 'baz'");
177 $this->mock->_checkArgIsElement("some_arg", "baz", array("foo", "bar"), "foobar");
178 }

◆ test_check_string_arg_not_ok()

ComponentHelperTest::test_check_string_arg_not_ok ( )

Definition at line 127 of file ComponentHelperTest.php.

127 : void
128 {
129 $this->expectException(InvalidArgumentException::class);
130 $this->expectExceptionMessage("Argument 'some_arg': expected string, got integer '1'");
131 $this->mock->_checkStringArg("some_arg", 1);
132 }

◆ test_check_string_arg_ok()

ComponentHelperTest::test_check_string_arg_ok ( )

@doesNotPerformAssertions

Definition at line 122 of file ComponentHelperTest.php.

122 : void
123 {
124 $this->mock->_checkStringArg("some_arg", "bar");
125 }

◆ test_getCanonicalName()

ComponentHelperTest::test_getCanonicalName ( )

Definition at line 98 of file ComponentHelperTest.php.

98 : void
99 {
100 $c = new TestComponent("foo");
101 $this->assertEquals("Test Component Test", $c->getCanonicalName());
102 }
$c
Definition: cli.php:38

References $c.

◆ test_to_array_with_array()

ComponentHelperTest::test_to_array_with_array ( )

Definition at line 180 of file ComponentHelperTest.php.

180 : void
181 {
182 $foo = array("foo", "bar");
183 $res = $this->mock->_toArray($foo);
184
185 $this->assertEquals($foo, $res);
186 }
$res
Definition: ltiservices.php:69

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

◆ test_to_array_with_int()

ComponentHelperTest::test_to_array_with_int ( )

Definition at line 188 of file ComponentHelperTest.php.

188 : void
189 {
190 $foo = 1;
191 $res = $this->mock->_toArray($foo);
192 $this->assertEquals(array($foo), $res);
193 }

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

Field Documentation

◆ $mock

ComponentMock ComponentHelperTest::$mock
protected

Definition at line 91 of file ComponentHelperTest.php.


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