19declare(strict_types=1);
24use PHPUnit\Framework\TestCase;
25use PHPUnit\Framework\Attributes\DataProvider;
29 #[DataProvider('constraintsProvider')]
32 $this->assertTrue($constraint->
accepts($okValue));
33 $this->assertFalse($constraint->
accepts($errorValue));
36 #[DataProvider('constraintsProvider')]
42 $constraint->
check($errorValue);
43 }
catch (UnexpectedValueException
$e) {
47 $this->assertTrue($raised);
50 $constraint->
check($okValue);
52 }
catch (UnexpectedValueException
$e) {
56 $this->assertFalse($raised);
59 #[DataProvider('constraintsProvider')]
62 $this->assertNull($constraint->
problemWith($okValue));
63 $this->assertIsString($constraint->
problemWith($errorValue));
66 #[DataProvider('constraintsProvider')]
69 $rf =
new DataFactory();
70 $ok = $rf->ok($okValue);
71 $ok2 = $rf->ok($errorValue);
72 $error = $rf->error(
'text');
74 $result = $constraint->
applyTo($ok);
75 $this->assertTrue($result->isOk());
77 $result = $constraint->
applyTo($ok2);
78 $this->assertTrue($result->isError());
80 $result = $constraint->
applyTo($error);
81 $this->assertSame($error, $result);
84 #[DataProvider('constraintsProvider')]
88 return "This was a vault";
90 $this->assertEquals(
"This was a vault", $new_constraint->problemWith($errorValue));
98 $language =
new class () implements \
ILIAS\Language\Language {
99 public function txt(
string $a_topic,
string $a_default_lang_fallback_mod =
""):
string
103 public function loadLanguageModule(
string $a_module):
void
106 public function getLangKey():
string
110 public function toJS($key):
void
114 $data_factory =
new DataFactory();
116 $refinery =
new Refinery($data_factory, $language);
testAccept(LogicalOr $constraint, mixed $okValue, mixed $errorValue)
testProblemWith(LogicalOr $constraint, mixed $okValue, mixed $errorValue)
testWithProblemBuilder(LogicalOr $constraint, mixed $okValue, mixed $errorValue)
testRestrict(LogicalOr $constraint, mixed $okValue, mixed $errorValue)
testCheck(LogicalOr $constraint, mixed $okValue, mixed $errorValue)
static constraintsProvider()
accepts($value)
Tells if the provided value complies.
applyTo(Result $result)
Restricts a Result.
check($value)
Checks the provided value.
problemWith($value)
Tells what the problem with the provided value is.
withProblemBuilder(callable $builder)
Get a constraint like this one with a builder for a custom error message.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.