Exemple #1
0
 public function testDefineWithInvalid()
 {
     $definition = Arguments::define(PrimitiveTypeConstraint::forType(ScalarTypes::SCALAR_STRING), EitherConstraint::create(MaybeConstraint::forType(PrimitiveTypeConstraint::forType(CompoundTypes::COMPOUND_ARRAY)), PrimitiveTypeConstraint::forType(ScalarTypes::SCALAR_BOOLEAN)));
     $definition->check('wow', true);
     $definition->check('wow', []);
     $definition->check('wow', null);
     $this->setExpectedException(InvalidArgumentException::class);
     $definition->check('wow', 25);
 }
 public function testCheck()
 {
     $instance = new MaybeConstraint(new PrimitiveTypeConstraint(ScalarTypes::SCALAR_STRING));
     $this->assertEqualsMatrix([[true, $instance->check(null)], [true, $instance->check('hello world')], [true, $instance->check('hello world' . null)], [false, $instance->check(27645)], [false, $instance->check(276.564)], [false, $instance->check(new stdClass())]]);
 }