4 require_once
'libs/composer/vendor/autoload.php';
24 $this->assertTrue($constraint->
accepts($okValue));
25 $this->assertFalse($constraint->
accepts($errorValue));
39 $constraint->
check($errorValue);
44 $this->assertTrue($raised);
47 $constraint->
check($okValue);
53 $this->assertFalse($raised);
64 $this->assertNull($constraint->
problemWith($okValue));
65 $this->assertInternalType(
'string', $constraint->
problemWith($errorValue));
76 $rf =
new Data\Factory();
77 $ok = $rf->ok($okValue);
78 $ok2 = $rf->ok($errorValue);
79 $error = $rf->error(
'text');
82 $this->assertTrue(
$result->isOk());
85 $this->assertTrue($result->isError());
87 $result = $constraint->
restrict($error);
88 $this->assertSame($error, $result);
100 return "This was a vault";
102 $this->assertEquals(
"This was a vault", $new_constraint->problemWith($errorValue));
110 $mock = $this->getMockBuilder(\ilLanguage::class)->disableOriginalConstructor()->getMock();
111 $f =
new Validation\Factory(
new Data\
Factory(), $mock);
114 [
$f->or([
$f->isInt(),
$f->isString()]),
'5', []],
115 [
$f->or([
$f->greaterThan(5),
$f->lessThan(2)]), 7, 3]
check($value)
Checks the provided value.Should not throw if accepts($value).
testRestrict(LogicalOr $constraint, $okValue, $errorValue)
constraintsProvider
testAccept(LogicalOr $constraint, $okValue, $errorValue)
constraintsProvider
testProblemWith(LogicalOr $constraint, $okValue, $errorValue)
constraintsProvider
accepts($value)
Tells if the provided value complies.bool
problemWith($value)
Tells what the problem with the provided value is.Should return null if accepts($value).string|null
withProblemBuilder(callable $builder)
Get a constraint like this one with a builder for a custom error message.problemWith() must return an...
restrict(Result $result)
Restricts a Result.Must do nothing with the result if $result->isError(). Must replace the result wit...
testCheck(LogicalOr $constraint, $okValue, $errorValue)
constraintsProvider
testWithProblemBuilder(LogicalOr $constraint, $okValue, $errorValue)
constraintsProvider