19 declare(strict_types=1);
25 require_once(
"vendor/composer/vendor/autoload.php");
27 require_once(__DIR__ .
"/../Renderer/TestComponent.php");
35 $this->checkArg($which, $check, $message);
40 $this->checkStringArg($which, $value);
45 $this->checkBoolArg($which, $value);
50 $this->checkArgInstanceOf($which, $value, $class);
55 $this->checkArgIsElement($which, $value, $array, $name);
60 return $this->toArray($value);
65 $this->checkArgListElements($which, $value, $classes);
70 $this->checkArgList($which, $value, $check, $message);
101 $this->assertEquals(
"Test Component Test",
$c->getCanonicalName());
109 $this->mock->_checkArg(
"some_arg",
true,
"some message");
114 $this->expectException(InvalidArgumentException::class);
115 $this->expectExceptionMessage(
"Argument 'some_arg': some message");
116 $this->mock->_checkArg(
"some_arg",
false,
"some message");
124 $this->mock->_checkStringArg(
"some_arg",
"bar");
129 $this->expectException(InvalidArgumentException::class);
130 $this->expectExceptionMessage(
"Argument 'some_arg': expected string, got integer '1'");
131 $this->mock->_checkStringArg(
"some_arg", 1);
139 $this->mock->_checkBoolArg(
"some_arg",
true);
144 $this->expectException(InvalidArgumentException::class);
145 $this->expectExceptionMessage(
"Argument 'some_arg': expected bool, got integer '1'");
146 $this->mock->_checkBoolArg(
"some_arg", 1);
154 $this->mock->_checkArgInstanceOf(
"some_arg", $this->mock, ComponentMock::class);
159 $this->expectException(InvalidArgumentException::class);
160 $this->expectExceptionMessage(
"Argument 'some_arg': expected ComponentMock, got ComponentHelperTest");
161 $this->mock->_checkArgInstanceOf(
"some_arg", $this, ComponentMock::class);
170 $this->mock->_checkArgIsElement(
"some_arg",
"bar", array(
"foo",
"bar"),
"foobar");
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");
182 $foo = array(
"foo",
"bar");
192 $this->assertEquals(array(
$foo),
$res);
201 $this->mock->_checkArgListElements(
"some_arg", $l, array(
"Class1"));
206 $this->expectException(InvalidArgumentException::class);
207 $this->expectExceptionMessage(
"Argument 'some_arg': expected Class1, got Class2");
209 $this->mock->_checkArgListElements(
"some_arg", $l, array(
"Class1"));
218 $this->mock->_checkArgListElements(
"some_arg", $l, array(
"Class1",
"Class2"));
223 $this->expectException(InvalidArgumentException::class);
224 $this->expectExceptionMessage(
"Argument 'some_arg': expected Class1, Class2, got Class3");
226 $this->mock->_checkArgListElements(
"some_arg", $l, array(
"Class1",
"Class2"));
234 $l = array(1,
"foo");
235 $this->mock->_checkArgListElements(
"some_arg", $l, array(
"string",
"int"));
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"));
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)";
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)";
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)";
_checkArgListElements(string $which, array &$value, $classes)
_checkBoolArg(string $which, $value)
testCheckArgListElementsStringOrIntNotOk()
_checkArg(string $which, bool $check, string $message)
testCheckStringArgNotOk()
_checkStringArg(string $which, $value)
testCheckArgInstanceofOk()
testCheckArgListElementsStringOrIntOk()
testCheckArgListElementsNoOk()
testCheckArgListElementsMultiClassOk()
testCheckArgIsElementOk()
_checkArgIsElement(string $which, $value, array $array, string $name)
testCheckStringArgIsElementNotOk()
testCheckArgListElementsOk()
testCheckArgListElementsMultiClassNotOk()
testCheckArgInstanceofNotOk()
_checkArgInstanceOf(string $which, $value, string $class)
_checkArgList(string $which, array &$value, Closure $check, Closure $message)