◆ setUp()
ComponentHelperTest::setUp |
( |
| ) |
|
◆ testCheckArgInstanceofNotOk()
ComponentHelperTest::testCheckArgInstanceofNotOk |
( |
| ) |
|
Definition at line 158 of file ComponentHelperTest.php.
160 $this->expectException(InvalidArgumentException::class);
161 $this->expectExceptionMessage(
"Argument 'some_arg': expected ComponentMock, got ComponentHelperTest");
162 $this->mock->_checkArgInstanceOf(
"some_arg", $this, ComponentMock::class);
◆ testCheckArgInstanceofOk()
ComponentHelperTest::testCheckArgInstanceofOk |
( |
| ) |
|
Definition at line 153 of file ComponentHelperTest.php.
155 $this->mock->_checkArgInstanceOf(
"some_arg", $this->mock, ComponentMock::class);
◆ testCheckArgIsElementOk()
ComponentHelperTest::testCheckArgIsElementOk |
( |
| ) |
|
Definition at line 167 of file ComponentHelperTest.php.
169 $this->mock->_checkArgIsElement(
"some_arg",
"bar", array(
"foo",
"bar"),
"foobar");
◆ testCheckArgListElementsMultiClassNotOk()
ComponentHelperTest::testCheckArgListElementsMultiClassNotOk |
( |
| ) |
|
Definition at line 216 of file ComponentHelperTest.php.
218 $this->expectException(InvalidArgumentException::class);
219 $this->expectExceptionMessage(
"Argument 'some_arg': expected Class1, Class2, got Class3");
221 $this->mock->_checkArgListElements(
"some_arg", $l, array(
"Class1",
"Class2"));
◆ testCheckArgListElementsMultiClassOk()
ComponentHelperTest::testCheckArgListElementsMultiClassOk |
( |
| ) |
|
Definition at line 210 of file ComponentHelperTest.php.
213 $this->mock->_checkArgListElements(
"some_arg", $l, array(
"Class1",
"Class2"));
◆ testCheckArgListElementsNoOk()
ComponentHelperTest::testCheckArgListElementsNoOk |
( |
| ) |
|
Definition at line 201 of file ComponentHelperTest.php.
203 $this->expectException(InvalidArgumentException::class);
204 $this->expectExceptionMessage(
"Argument 'some_arg': expected Class1, got Class2");
206 $this->mock->_checkArgListElements(
"some_arg", $l, array(
"Class1"));
◆ testCheckArgListElementsOk()
ComponentHelperTest::testCheckArgListElementsOk |
( |
| ) |
|
◆ testCheckArgListElementsStringOrIntNotOk()
ComponentHelperTest::testCheckArgListElementsStringOrIntNotOk |
( |
| ) |
|
Definition at line 231 of file ComponentHelperTest.php.
233 $this->expectException(InvalidArgumentException::class);
234 $this->expectExceptionMessage(
"Argument 'some_arg': expected string, int, got Class1");
235 $l = array(1,
new Class1());
236 $this->mock->_checkArgListElements(
"some_arg", $l, array(
"string",
"int"));
◆ testCheckArgListElementsStringOrIntOk()
ComponentHelperTest::testCheckArgListElementsStringOrIntOk |
( |
| ) |
|
Definition at line 225 of file ComponentHelperTest.php.
227 $l = array(1,
"foo");
228 $this->mock->_checkArgListElements(
"some_arg", $l, array(
"string",
"int"));
◆ testCheckArgListNotOk1()
ComponentHelperTest::testCheckArgListNotOk1 |
( |
| ) |
|
Definition at line 250 of file ComponentHelperTest.php.
252 $m =
"expected keys of type string and integer values, got (4 => 3)";
253 $this->expectException(InvalidArgumentException::class);
254 $this->expectExceptionMessage(
"Argument 'some_arg': $m");
255 $l = array(
"a" => 1,
"b" => 2, 4 => 3);
256 $this->mock->_checkArgList(
"some_arg", $l,
function ($k, $v) {
257 return is_string($k) && is_int($v);
258 },
function ($k, $v) {
259 return "expected keys of type string and integer values, got ($k => $v)";
◆ testCheckArgListNotOk2()
ComponentHelperTest::testCheckArgListNotOk2 |
( |
| ) |
|
Definition at line 263 of file ComponentHelperTest.php.
265 $m =
"expected keys of type string and integer values, got (c => d)";
266 $this->expectException(InvalidArgumentException::class);
267 $this->expectExceptionMessage(
"Argument 'some_arg': $m");
268 $l = array(
"a" => 1,
"b" => 2,
"c" =>
"d");
269 $this->mock->_checkArgList(
"some_arg", $l,
function ($k, $v) {
270 return is_string($k) && is_int($v);
271 },
function ($k, $v) {
272 return "expected keys of type string and integer values, got ($k => $v)";
◆ testCheckArgListOk()
ComponentHelperTest::testCheckArgListOk |
( |
| ) |
|
Definition at line 240 of file ComponentHelperTest.php.
242 $l = array(
"a" => 1,
"b" => 2,
"c" => 3);
243 $this->mock->_checkArgList(
"some_arg", $l,
function ($k, $v) {
244 return is_string($k) && is_int($v);
245 },
function ($k, $v) {
246 return "expected keys of type string and integer values, got ($k => $v)";
◆ testCheckArgNotOk()
ComponentHelperTest::testCheckArgNotOk |
( |
| ) |
|
Definition at line 119 of file ComponentHelperTest.php.
121 $this->expectException(InvalidArgumentException::class);
122 $this->expectExceptionMessage(
"Argument 'some_arg': some message");
123 $this->mock->_checkArg(
"some_arg",
false,
"some message");
◆ testCheckArgOk()
ComponentHelperTest::testCheckArgOk |
( |
| ) |
|
◆ testCheckBoolArgNotOk()
ComponentHelperTest::testCheckBoolArgNotOk |
( |
| ) |
|
Definition at line 145 of file ComponentHelperTest.php.
147 $this->expectException(InvalidArgumentException::class);
148 $this->expectExceptionMessage(
"Argument 'some_arg': expected bool, got integer '1'");
149 $this->mock->_checkBoolArg(
"some_arg", 1);
◆ testCheckBoolArgOk()
ComponentHelperTest::testCheckBoolArgOk |
( |
| ) |
|
◆ testCheckStringArgIsElementNotOk()
ComponentHelperTest::testCheckStringArgIsElementNotOk |
( |
| ) |
|
Definition at line 172 of file ComponentHelperTest.php.
174 $this->expectException(InvalidArgumentException::class);
175 $this->expectExceptionMessage(
"Argument 'some_arg': expected foobar, got 'baz'");
176 $this->mock->_checkArgIsElement(
"some_arg",
"baz", array(
"foo",
"bar"),
"foobar");
◆ testCheckStringArgNotOk()
ComponentHelperTest::testCheckStringArgNotOk |
( |
| ) |
|
Definition at line 132 of file ComponentHelperTest.php.
134 $this->expectException(InvalidArgumentException::class);
135 $this->expectExceptionMessage(
"Argument 'some_arg': expected string, got integer '1'");
136 $this->mock->_checkStringArg(
"some_arg", 1);
◆ testCheckStringArgOk()
ComponentHelperTest::testCheckStringArgOk |
( |
| ) |
|
◆ testGetCanonicalName()
ComponentHelperTest::testGetCanonicalName |
( |
| ) |
|
◆ testReduceWith()
ComponentHelperTest::testReduceWith |
( |
| ) |
|
◆ testReduceWithDoesNotModify()
ComponentHelperTest::testReduceWithDoesNotModify |
( |
| ) |
|
Definition at line 300 of file ComponentHelperTest.php.
References Vendor\Package\$a, Vendor\Package\$b, $c, Vendor\Package\$f, and $res.
303 $a->random_data =
"A";
305 $b->random_data =
"B";
307 $c->random_data =
"C";
308 $c->sub_components = [
$a,
$b];
312 $clone->random_data = strtolower($c->random_data);
313 $clone->sub_components =
$res;
316 $c2 =
$c->reduceWith(
$f);
318 [$a2, $b2] = $c2->sub_components;
320 $this->assertNotEquals(spl_object_id(
$a), spl_object_id($a2));
321 $this->assertNotEquals(spl_object_id(
$b), spl_object_id($b2));
322 $this->assertNotEquals(spl_object_id(
$c), spl_object_id($c2));
324 $this->assertEquals(
"A",
$a->random_data);
325 $this->assertEquals(
"B",
$b->random_data);
326 $this->assertEquals(
"C",
$c->random_data);
327 $this->assertEquals([
$a,
$b],
$c->sub_components);
329 $this->assertEquals(
"a", $a2->random_data);
330 $this->assertEquals(
"b", $b2->random_data);
331 $this->assertEquals(
"c", $c2->random_data);
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
◆ testReduceWithSubStructureIsTransient()
ComponentHelperTest::testReduceWithSubStructureIsTransient |
( |
| ) |
|
◆ testToArrayWithArray()
ComponentHelperTest::testToArrayWithArray |
( |
| ) |
|
◆ testToArrayWithInt()
ComponentHelperTest::testToArrayWithInt |
( |
| ) |
|
◆ $mock
The documentation for this class was generated from the following file: