TestCase for the custom constraints.
More...
◆ setUp()
ValidationConstraintsCustomTest::setUp |
( |
| ) |
|
Definition at line 42 of file CustomTest.php.
42 : void
43 {
44 $is_ok = function ($value) {
45 return false;
46 };
47 $this->txt_id = "TXT_ID";
48 $error =
function (callable
$txt, $value) {
49 return $txt($this->txt_id, $value);
50 };
51 $this->lng = $this->createMock(\ilLanguage::class);
53 }
References $txt.
◆ test_exception_on_no_parameter()
ValidationConstraintsCustomTest::test_exception_on_no_parameter |
( |
| ) |
|
Definition at line 88 of file CustomTest.php.
89 {
90 $lng_closure = $this->constraint->_getLngClosure();
91
92 $this->expectException(\InvalidArgumentException::class);
93
94 $lng_closure();
95 }
◆ test_gracefully_handle_arrays_and_objects()
ValidationConstraintsCustomTest::test_gracefully_handle_arrays_and_objects |
( |
| ) |
|
Definition at line 113 of file CustomTest.php.
114 {
115 $lng_closure = $this->constraint->_getLngClosure();
116
117 $this->lng
118 ->expects($this->once())
119 ->method("txt")
120 ->with("id")
121 ->willReturn("%s-%s-%s-%s-");
122
124
125 $res = $lng_closure(
"id", [],
new \stdClass(),
"foo",
null);
126
127 $this->assertEquals(
"array-" . \stdClass::class .
"-foo-null-",
$res);
128 }
foreach($_POST as $key=> $value) $res
References $res.
◆ test_no_sprintf_on_one_parameter()
ValidationConstraintsCustomTest::test_no_sprintf_on_one_parameter |
( |
| ) |
|
Definition at line 97 of file CustomTest.php.
98 {
99 $lng_closure = $this->constraint->_getLngClosure();
100
101 $txt_out = "txt";
102 $this->lng
103 ->expects($this->once())
104 ->method("txt")
105 ->with($this->txt_id)
106 ->willReturn($txt_out);
107
108 $res = $lng_closure($this->txt_id);
109
110 $this->assertEquals($txt_out,
$res);
111 }
References $res.
◆ test_use_txt()
ValidationConstraintsCustomTest::test_use_txt |
( |
| ) |
|
Definition at line 73 of file CustomTest.php.
74 {
75 $txt_out = "'%s'";
76 $this->lng
77 ->expects($this->once())
78 ->method("txt")
79 ->with($this->txt_id)
80 ->willReturn($txt_out);
81
82 $value = "VALUE";
83 $problem = $this->constraint->problemWith($value);
84
85 $this->assertEquals(sprintf($txt_out, $value), $problem);
86 }
◆ testProblemBuilderRetrievesLngClosure()
ValidationConstraintsCustomTest::testProblemBuilderRetrievesLngClosure |
( |
| ) |
|
Definition at line 63 of file CustomTest.php.
64 {
65 $c = $this->constraint->withProblemBuilder(
function (
$txt) {
67 return "";
68 });
70 $this->assertTrue(is_callable($this->cls));
71 }
References Vendor\Package\$c, and $txt.
◆ testWithProblemBuilder()
ValidationConstraintsCustomTest::testWithProblemBuilder |
( |
| ) |
|
Definition at line 55 of file CustomTest.php.
56 {
57 $new_constraint = $this->constraint->withProblemBuilder(function () {
58 return "This was a fault";
59 });
60 $this->assertEquals("This was a fault", $new_constraint->problemWith(""));
61 }
◆ $f
ValidationConstraintsCustomTest::$f = null |
|
protected |
◆ $txt_id
ValidationConstraintsCustomTest::$txt_id = '' |
|
protected |
The documentation for this class was generated from the following file: