Definition at line 25 of file CustomTest.php.
◆ setUp()
Definition at line 31 of file CustomTest.php.
References $lng, $txt, ILIAS\Refinery\getLngClosure(), and ILIAS\Repository\lng().
33 $is_ok =
static function ($value):
bool {
36 $this->txt_id =
"TXT_ID";
37 $error =
function (callable
$txt, $value):
string {
38 return $txt($this->txt_id, $value);
40 $this->
lng = $this->createMock(
ILIAS\Language\Language::class);
42 public function _getLngClosure():
Closure Interface Observer Contains several chained tasks and infos about them.
ILIAS Language Language $lng
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getLngClosure()
Get the closure to be passed to the error-function that does i18n and sprintf.
◆ test_exception_on_no_parameter()
| CustomTest::test_exception_on_no_parameter |
( |
| ) |
|
Definition at line 83 of file CustomTest.php.
85 $lng_closure = $this->constraint->_getLngClosure();
87 $this->expectException(ArgumentCountError::class);
◆ test_gracefully_handle_arrays_and_objects()
| CustomTest::test_gracefully_handle_arrays_and_objects |
( |
| ) |
|
Definition at line 108 of file CustomTest.php.
References $res, and ILIAS\Repository\lng().
110 $lng_closure = $this->constraint->_getLngClosure();
113 ->expects($this->once())
116 ->willReturn(
"%s-%s-%s-%s-");
118 $res = $lng_closure(
"id", [],
new stdClass(),
"foo", null);
120 $this->assertEquals(
"array-" . stdClass::class .
"-foo-null-",
$res);
◆ test_no_sprintf_on_one_parameter()
| CustomTest::test_no_sprintf_on_one_parameter |
( |
| ) |
|
Definition at line 92 of file CustomTest.php.
References $res, and ILIAS\Repository\lng().
94 $lng_closure = $this->constraint->_getLngClosure();
98 ->expects($this->once())
100 ->with($this->txt_id)
101 ->willReturn($txt_out);
103 $res = $lng_closure($this->txt_id);
105 $this->assertEquals($txt_out,
$res);
◆ test_use_txt()
| CustomTest::test_use_txt |
( |
| ) |
|
Definition at line 68 of file CustomTest.php.
References ILIAS\Repository\lng().
72 ->expects($this->once())
75 ->willReturn($txt_out);
78 $problem = $this->constraint->problemWith($value);
80 $this->assertEquals(sprintf($txt_out, $value), $problem);
◆ testProblemBuilderRetrievesLngClosure()
| CustomTest::testProblemBuilderRetrievesLngClosure |
( |
| ) |
|
Definition at line 57 of file CustomTest.php.
References $c, and $txt.
60 $c = $this->constraint->withProblemBuilder(
function (
$txt) use (&$cls):
string {
65 $this->assertIsCallable($cls);
◆ testWithProblemBuilder()
| CustomTest::testWithProblemBuilder |
( |
| ) |
|
Definition at line 49 of file CustomTest.php.
51 $new_constraint = $this->constraint->withProblemBuilder(
static function ():
string {
52 return "This was a fault";
54 $this->assertEquals(
"This was a fault", $new_constraint->problemWith(
""));
◆ $constraint
| CustomConstraint CustomTest::$constraint |
|
private |
◆ $lng
| ILIAS Language Language CustomTest::$lng |
|
private |
◆ $txt_id
| string CustomTest::$txt_id = '' |
|
private |
The documentation for this class was generated from the following file: