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