5 require_once(
"libs/composer/vendor/autoload.php");
8 use \ILIAS\UI\Implementation\Component\ComponentHelper;
10 public function _checkArg($which, $check, $message) {
11 $this->checkArg($which, $check, $message);
14 $this->checkIntArg($which, $value);
17 $this->checkStringArg($which, $value);
20 $this->checkArgInstanceOf($which, $value, $class);
23 $this->checkArgIsElement($which, $value, $array, $name);
26 return $this->toArray($value);
29 $this->checkArgListElements($which, $value, $classes);
32 $this->checkArgList($which, $value, $check, $message);
53 $this->mock->_checkArg(
"some_arg",
true,
"some message");
56 $this->assertFalse(
"This should not happen.");
62 $this->mock->_checkArg(
"some_arg",
false,
"some message");
63 $this->assertFalse(
"This should not happen.");
66 $this->assertEquals(
"Argument 'some_arg': some message", $e->getMessage());
72 $this->mock->_checkIntArg(
"some_arg", 1);
75 $this->assertFalse(
"This should not happen.");
81 $this->mock->_checkIntArg(
"some_arg",
"foo");
82 $this->assertFalse(
"This should not happen.");
85 $this->assertEquals(
"Argument 'some_arg': expected integer, got string 'foo'", $e->getMessage());
91 $this->mock->_checkStringArg(
"some_arg",
"bar");
94 $this->assertFalse(
"This should not happen.");
100 $this->mock->_checkStringArg(
"some_arg", 1);
101 $this->assertFalse(
"This should not happen.");
104 $this->assertEquals(
"Argument 'some_arg': expected string, got integer '1'", $e->getMessage());
110 $this->mock->_checkArgInstanceOf(
"some_arg", $this->mock, ComponentMock::class);
113 $this->assertFalse(
"This should not happen.");
119 $this->mock->_checkArgInstanceOf(
"some_arg", $this, ComponentMock::class);
120 $this->assertFalse(
"This should not happen.");
123 $this->assertEquals(
"Argument 'some_arg': expected ComponentMock, got ComponentHelperTest", $e->getMessage());
131 $this->mock->_checkArgIsElement(
"some_arg",
"bar",
array(
"foo",
"bar"),
"foobar");
134 $this->assertFalse(
"This should not happen.");
140 $this->mock->_checkArgIsElement(
"some_arg",
"baz",
array(
"foo",
"bar"),
"foobar");
141 $this->assertFalse(
"This should not happen.");
144 $this->assertEquals(
"Argument 'some_arg': expected foobar, got 'baz'", $e->getMessage());
149 $foo =
array(
"foo",
"bar");
150 $res = $this->mock->_toArray($foo);
152 $this->assertEquals($foo,
$res);
157 $res = $this->mock->_toArray($foo);
164 $this->mock->_checkArgListElements(
"some_arg",
$l,
array(
"Class1"));
167 $this->assertFalse(
"This should not happen.");
174 $this->mock->_checkArgListElements(
"some_arg",
$l,
array(
"Class1"));
175 $this->assertFalse(
"This should not happen.");
178 $this->assertEquals(
"Argument 'some_arg': expected Class1, got Class2", $e->getMessage());
185 $this->mock->_checkArgListElements(
"some_arg",
$l,
array(
"Class1",
"Class2"));
188 $this->assertFalse(
"This should not happen.");
195 $this->mock->_checkArgListElements(
"some_arg",
$l,
array(
"Class1",
"Class2"));
196 $this->assertFalse(
"This should not happen.");
199 $this->assertEquals(
"Argument 'some_arg': expected Class1, Class2, got Class3", $e->getMessage());
206 $this->mock->_checkArgListElements(
"some_arg",
$l,
array(
"string",
"int"));
209 $this->assertFalse(
"This should not happen.");
216 $this->mock->_checkArgListElements(
"some_arg",
$l,
array(
"string",
"int"));
217 $this->assertFalse(
"This should not happen.");
220 $this->assertEquals(
"Argument 'some_arg': expected string, int, got Class1", $e->getMessage());
225 $l =
array(
"a" => 1,
"b" => 2,
"c" => 3);
227 $this->mock->_checkArgList
231 return is_string($k) && is_int($v);
234 return "expected keys of type string and integer values, got ($k => $v)";
238 $this->assertFalse(
"This should not happen.");
243 $l =
array(
"a" => 1,
"b" => 2, 4 => 3);
245 $this->mock->_checkArgList
249 return is_string($k) && is_int($v);
252 return "expected keys of type string and integer values, got ($k => $v)";
254 $this->assertFalse(
"This should not happen.");
257 $m =
"expected keys of type string and integer values, got (4 => 3)";
258 $this->assertEquals(
"Argument 'some_arg': $m", $e->getMessage());
263 $l =
array(
"a" => 1,
"b" => 2,
"c" =>
"d");
265 $this->mock->_checkArgList
269 return is_string($k) && is_int($v);
272 return "expected keys of type string and integer values, got ($k => $v)";
275 $this->assertFalse(
"This should not happen.");
278 $m =
"expected keys of type string and integer values, got (c => d)";
279 $this->assertEquals(
"Argument 'some_arg': $m", $e->getMessage());
_checkArgList($which, &$value, $check, $message)
test_check_int_arg_not_ok()
_checkArgListElements($which, &$value, $classes)
test_check_arg_list_elements_multi_class_not_ok()
test_check_string_arg_is_element_not_ok()
test_check_arg_list_elements_no_ok()
test_check_arg_list_elements_ok()
test_check_arg_instanceof_ok()
test_check_arg_list_elements_string_or_int_not_ok()
_checkArg($which, $check, $message)
test_check_arg_list_not_ok_1()
test_check_string_arg_not_ok()
test_to_array_with_array()
test_check_arg_list_elements_string_or_int_ok()
test_check_arg_list_elements_multi_class_ok()
_checkArgIsElement($which, $value, $array, $name)
test_check_arg_instanceof_not_ok()
Create styles array
The data for the language used.
_checkStringArg($which, $value)
_checkArgInstanceOf($which, $value, $class)
test_check_string_arg_ok()
_checkIntArg($which, $value)
test_check_arg_is_element_ok()
test_check_arg_list_not_ok_2()