3declare(strict_types=1);
24use PHPUnit\Framework\TestCase;
36 $this->assertTrue($constraint->
accepts($okValue));
37 $this->assertFalse($constraint->
accepts($errorValue));
51 $constraint->
check($errorValue);
52 }
catch (UnexpectedValueException
$e) {
56 $this->assertTrue($raised);
59 $constraint->
check($okValue);
61 }
catch (UnexpectedValueException
$e) {
65 $this->assertFalse($raised);
76 $this->assertNull($constraint->
problemWith($okValue));
77 $this->assertIsString($constraint->
problemWith($errorValue));
88 $rf =
new DataFactory();
89 $ok = $rf->ok($okValue);
90 $ok2 = $rf->ok($errorValue);
91 $error = $rf->error(
'text');
93 $result = $constraint->
applyTo($ok);
94 $this->assertTrue($result->isOk());
96 $result = $constraint->
applyTo($ok2);
97 $this->assertTrue($result->isError());
99 $result = $constraint->
applyTo($error);
100 $this->assertSame($error, $result);
112 return "This was a vault";
114 $this->assertEquals(
"This was a vault", $new_constraint->problemWith($errorValue));
122 $mock = $this->getMockBuilder(ilLanguage::class)->disableOriginalConstructor()->getMock();
123 $data_factory =
new DataFactory();
125 $refinery =
new Refinery($data_factory, $mock);
testRestrict(LogicalOr $constraint, $okValue, $errorValue)
@dataProvider constraintsProvider
testWithProblemBuilder(LogicalOr $constraint, $okValue, $errorValue)
@dataProvider constraintsProvider
testAccept(LogicalOr $constraint, $okValue, $errorValue)
@dataProvider constraintsProvider
testProblemWith(LogicalOr $constraint, $okValue, $errorValue)
@dataProvider constraintsProvider
testCheck(LogicalOr $constraint, $okValue, $errorValue)
@dataProvider 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.
Refinery Factory $refinery