Definition at line 43 of file CustomTest.php.
◆ setUp()
| ValidationConstraintsCustomTest::setUp |
( |
| ) |
|
|
protected |
Definition at line 49 of file CustomTest.php.
49 : void
50 {
51 $is_ok = static function ($value): bool {
52 return false;
53 };
54 $this->txt_id = "TXT_ID";
55 $error =
function (callable
$txt, $value):
string {
56 return $txt($this->txt_id, $value);
57 };
58 $this->
lng = $this->createMock(ilLanguage::class);
60 }
References $txt, and ILIAS\Repository\lng().
◆ test_exception_on_no_parameter()
| ValidationConstraintsCustomTest::test_exception_on_no_parameter |
( |
| ) |
|
Definition at line 96 of file CustomTest.php.
96 : void
97 {
98 $lng_closure = $this->constraint->_getLngClosure();
99
100 $this->expectException(InvalidArgumentException::class);
101
102 $lng_closure();
103 }
◆ test_gracefully_handle_arrays_and_objects()
| ValidationConstraintsCustomTest::test_gracefully_handle_arrays_and_objects |
( |
| ) |
|
Definition at line 121 of file CustomTest.php.
121 : void
122 {
123 $lng_closure = $this->constraint->_getLngClosure();
124
126 ->expects($this->once())
127 ->method("txt")
128 ->with("id")
129 ->willReturn("%s-%s-%s-%s-");
130
132
133 $res = $lng_closure(
"id", [],
new stdClass(),
"foo",
null);
134
135 $this->assertEquals(
"array-" . stdClass::class .
"-foo-null-",
$res);
136 }
References $res, and ILIAS\Repository\lng().
◆ test_no_sprintf_on_one_parameter()
| ValidationConstraintsCustomTest::test_no_sprintf_on_one_parameter |
( |
| ) |
|
Definition at line 105 of file CustomTest.php.
105 : void
106 {
107 $lng_closure = $this->constraint->_getLngClosure();
108
109 $txt_out = "txt";
111 ->expects($this->once())
112 ->method("txt")
113 ->with($this->txt_id)
114 ->willReturn($txt_out);
115
116 $res = $lng_closure($this->txt_id);
117
118 $this->assertEquals($txt_out,
$res);
119 }
References $res, and ILIAS\Repository\lng().
◆ test_use_txt()
| ValidationConstraintsCustomTest::test_use_txt |
( |
| ) |
|
Definition at line 81 of file CustomTest.php.
81 : void
82 {
83 $txt_out = "'%s'";
85 ->expects($this->once())
86 ->method("txt")
87 ->with($this->txt_id)
88 ->willReturn($txt_out);
89
90 $value = "VALUE";
91 $problem = $this->constraint->problemWith($value);
92
93 $this->assertEquals(sprintf($txt_out, $value), $problem);
94 }
References ILIAS\Repository\lng().
◆ testProblemBuilderRetrievesLngClosure()
| ValidationConstraintsCustomTest::testProblemBuilderRetrievesLngClosure |
( |
| ) |
|
Definition at line 70 of file CustomTest.php.
70 : void
71 {
72 $cls = null;
73 $c = $this->constraint->withProblemBuilder(
function (
$txt) use (&$cls):
string {
75 return "";
76 });
78 $this->assertIsCallable($cls);
79 }
References $c, and $txt.
◆ testWithProblemBuilder()
| ValidationConstraintsCustomTest::testWithProblemBuilder |
( |
| ) |
|
Definition at line 62 of file CustomTest.php.
62 : void
63 {
64 $new_constraint = $this->constraint->withProblemBuilder(static function (): string {
65 return "This was a fault";
66 });
67 $this->assertEquals("This was a fault", $new_constraint->problemWith(""));
68 }
◆ $constraint
◆ $lng
◆ $txt_id
| string ValidationConstraintsCustomTest::$txt_id = '' |
|
private |
The documentation for this class was generated from the following file: