Definition at line 9 of file IsArrayOfConstraintTest.php.
◆ setUp()
IsArrayOfConstraintTest::setUp |
( |
| ) |
|
Definition at line 11 of file IsArrayOfConstraintTest.php.
13 $this->df =
new Data\Factory();
14 $this->lng = $this->createMock(\ilLanguage::class);
15 $this->f =
new Validation\Factory($this->df, $this->lng);
17 $this->on_element = $this->createMock(Validation\Constraint::class);
19 $this->c = $this->f->isArrayOf($this->on_element);
◆ testAccepts()
IsArrayOfConstraintTest::testAccepts |
( |
| ) |
|
Definition at line 22 of file IsArrayOfConstraintTest.php.
25 ->expects($this->exactly(2))
27 ->withConsecutive([1], [2])
28 ->will($this->onConsecutiveCalls(
true,
true));
30 $this->assertTrue($this->c->accepts([1, 2]));
◆ testCheckFails()
IsArrayOfConstraintTest::testCheckFails |
( |
| ) |
|
Definition at line 61 of file IsArrayOfConstraintTest.php.
64 ->expects($this->exactly(2))
66 ->withConsecutive([1], [2])
67 ->will($this->onConsecutiveCalls(
true,
false));
69 $this->expectException(\UnexpectedValueException::class);
70 $this->c->check([1, 2]);
◆ testCheckFailsOnNoneArray()
IsArrayOfConstraintTest::testCheckFailsOnNoneArray |
( |
| ) |
|
◆ testCheckSucceed()
IsArrayOfConstraintTest::testCheckSucceed |
( |
| ) |
|
Definition at line 49 of file IsArrayOfConstraintTest.php.
52 ->expects($this->exactly(2))
54 ->withConsecutive([1], [2])
55 ->will($this->onConsecutiveCalls(
true,
true));
57 $this->c->check([1, 2]);
58 $this->assertTrue(
true);
◆ testNoProblemWith()
IsArrayOfConstraintTest::testNoProblemWith |
( |
| ) |
|
Definition at line 80 of file IsArrayOfConstraintTest.php.
83 ->expects($this->exactly(2))
85 ->withConsecutive([1], [2])
86 ->will($this->onConsecutiveCalls(
true,
true));
88 $this->assertNull($this->c->problemWith([1, 2]));
◆ testNotAccepts()
IsArrayOfConstraintTest::testNotAccepts |
( |
| ) |
|
Definition at line 33 of file IsArrayOfConstraintTest.php.
36 ->expects($this->exactly(2))
38 ->withConsecutive([1], [2])
39 ->will($this->onConsecutiveCalls(
true,
false));
41 $this->assertFalse($this->c->accepts([1, 2, 3]));
◆ testNotAcceptsNoneArrays()
IsArrayOfConstraintTest::testNotAcceptsNoneArrays |
( |
| ) |
|
◆ testProblemWith()
IsArrayOfConstraintTest::testProblemWith |
( |
| ) |
|
Definition at line 91 of file IsArrayOfConstraintTest.php.
94 ->expects($this->exactly(3))
95 ->method(
"problemWith")
96 ->withConsecutive([1], [2], [3])
97 ->will($this->onConsecutiveCalls(null,
"2",
"3"));
100 ->expects($this->exactly(1))
102 ->withConsecutive([
"not_an_array_of"])
103 ->willReturn(
"-%s-");
105 $this->assertEquals(
"-2 3-", $this->c->problemWith([1,2,3]));
◆ testProblemWithNoneArray()
IsArrayOfConstraintTest::testProblemWithNoneArray |
( |
| ) |
|
Definition at line 108 of file IsArrayOfConstraintTest.php.
111 ->expects($this->exactly(1))
113 ->withConsecutive([
"not_an_array"])
114 ->willReturn(
"-%s-");
116 $this->assertEquals(
"-integer-", $this->c->problemWith(1));
◆ testRestrictError()
IsArrayOfConstraintTest::testRestrictError |
( |
| ) |
|
Definition at line 155 of file IsArrayOfConstraintTest.php.
References $res.
157 $error = $this->df->error(
"error");
159 $res = $this->c->restrict($error);
160 $this->assertSame($error,
$res);
foreach($_POST as $key=> $value) $res
◆ testRestrictNotOk()
IsArrayOfConstraintTest::testRestrictNotOk |
( |
| ) |
|
Definition at line 133 of file IsArrayOfConstraintTest.php.
References $res.
136 ->expects($this->exactly(2))
138 ->withConsecutive([1], [2])
139 ->will($this->onConsecutiveCalls(
true,
false));
141 $not_ok = $this->df->ok([1,2]);
143 $res = $this->c->restrict($not_ok);
144 $this->assertFalse(
$res->isOk());
foreach($_POST as $key=> $value) $res
◆ testRestrictNotOkForNoneArray()
IsArrayOfConstraintTest::testRestrictNotOkForNoneArray |
( |
| ) |
|
Definition at line 147 of file IsArrayOfConstraintTest.php.
References $res.
149 $not_ok = $this->df->ok(1);
151 $res = $this->c->restrict($not_ok);
152 $this->assertFalse(
$res->isOk());
foreach($_POST as $key=> $value) $res
◆ testRestrictOk()
IsArrayOfConstraintTest::testRestrictOk |
( |
| ) |
|
Definition at line 119 of file IsArrayOfConstraintTest.php.
References $ok, and $res.
122 ->expects($this->exactly(2))
124 ->withConsecutive([1], [2])
125 ->will($this->onConsecutiveCalls(
true,
true));
127 $ok = $this->df->ok([1, 2]);
129 $res = $this->c->restrict(
$ok);
130 $this->assertTrue(
$res->isOk());
foreach($_POST as $key=> $value) $res
◆ testWithProblemBuilder()
IsArrayOfConstraintTest::testWithProblemBuilder |
( |
| ) |
|
Definition at line 163 of file IsArrayOfConstraintTest.php.
165 $new_c = $this->c->withProblemBuilder(
function () {
166 return "This was a fault";
168 $this->assertEquals(
"This was a fault", $new_c->problemWith(2));
The documentation for this class was generated from the following file: