TestCase for the custom constraints.
More...
◆ setUp()
ValidationConstraintsCustomTest::setUp |
( |
| ) |
|
Definition at line 42 of file CustomTest.php.
References $txt.
44 $is_ok =
function ($value) {
47 $this->txt_id =
"TXT_ID";
48 $error =
function (callable
$txt, $value) {
49 return $txt($this->txt_id, $value);
51 $this->lng = $this->createMock(\ilLanguage::class);
◆ test_exception_on_no_parameter()
ValidationConstraintsCustomTest::test_exception_on_no_parameter |
( |
| ) |
|
Definition at line 88 of file CustomTest.php.
90 $lng_closure = $this->constraint->_getLngClosure();
92 $this->expectException(\InvalidArgumentException::class);
◆ test_gracefully_handle_arrays_and_objects()
ValidationConstraintsCustomTest::test_gracefully_handle_arrays_and_objects |
( |
| ) |
|
Definition at line 113 of file CustomTest.php.
References $res.
115 $lng_closure = $this->constraint->_getLngClosure();
118 ->expects($this->once())
121 ->willReturn(
"%s-%s-%s-%s-");
125 $res = $lng_closure(
"id", [],
new \
stdClass(),
"foo", null);
127 $this->assertEquals(
"array-" . \stdClass::class .
"-foo-null-",
$res);
foreach($_POST as $key=> $value) $res
◆ test_no_sprintf_on_one_parameter()
ValidationConstraintsCustomTest::test_no_sprintf_on_one_parameter |
( |
| ) |
|
Definition at line 97 of file CustomTest.php.
References $res.
99 $lng_closure = $this->constraint->_getLngClosure();
103 ->expects($this->once())
105 ->with($this->txt_id)
106 ->willReturn($txt_out);
108 $res = $lng_closure($this->txt_id);
110 $this->assertEquals($txt_out,
$res);
foreach($_POST as $key=> $value) $res
◆ test_use_txt()
ValidationConstraintsCustomTest::test_use_txt |
( |
| ) |
|
Definition at line 73 of file CustomTest.php.
77 ->expects($this->once())
80 ->willReturn($txt_out);
83 $problem = $this->constraint->problemWith($value);
85 $this->assertEquals(sprintf($txt_out, $value), $problem);
◆ testProblemBuilderRetrievesLngClosure()
ValidationConstraintsCustomTest::testProblemBuilderRetrievesLngClosure |
( |
| ) |
|
Definition at line 63 of file CustomTest.php.
References $c, and $txt.
65 $c = $this->constraint->withProblemBuilder(
function (
$txt) {
70 $this->assertTrue(is_callable($this->cls));
◆ testWithProblemBuilder()
ValidationConstraintsCustomTest::testWithProblemBuilder |
( |
| ) |
|
Definition at line 55 of file CustomTest.php.
57 $new_constraint = $this->constraint->withProblemBuilder(
function () {
58 return "This was a fault";
60 $this->assertEquals(
"This was a fault", $new_constraint->problemWith(
""));
◆ $f
ValidationConstraintsCustomTest::$f = null |
|
protected |
◆ $txt_id
ValidationConstraintsCustomTest::$txt_id = '' |
|
protected |
The documentation for this class was generated from the following file: