public function testMaxNumber() { $property = new Property($this->class, ['name' => 'myprop', 'max' => 3]); list($isValid, list($error)) = $property->validate(100); $this->assertFalse($isValid); $this->assertEquals('myprop must be at most 3.', $error); list($isValid, $errors) = $property->validate(3); $this->assertTrue($isValid); $this->assertEquals([], $errors); list($isValid, $errors) = $property->validate(-123); $this->assertTrue($isValid); $this->assertEquals([], $errors); list($isValid, $errors) = $property->validate(null); $this->assertTrue($isValid); $this->assertEquals([], $errors); }
/** * Instantiate a property instance based on the given configuration. * * @param array $config The configuration array * * @return PropertyInterface */ protected function instantiateProperty(array $config) { $property = Property::fromConfig($config); $property->setClass($this->class); return $property; }