/** * @expectedException \PSX\Data\Schema\ValidationException */ public function testVisitArrayMaxLength() { $visitor = new ValidationVisitor(); $property = Property::getArray('test')->setPrototype(Property::getString('foo')); $property->setMaxLength(1); $this->assertEquals(1, $property->getMaxLength()); $visitor->visitArray(array('foo', 'bar'), $property, ''); }
protected function parseArrayType(array $data, $name, $depth) { $arrayType = Property::getArray($name); if (isset($data['minItems'])) { $arrayType->setMinLength($data['minItems']); } if (isset($data['maxItems'])) { $arrayType->setMaxLength($data['maxItems']); } if (isset($data['items']) && is_array($data['items'])) { $property = $this->getRecProperty($data['items'], null, $depth + 1); if ($property !== null) { $arrayType->setPrototype($property); } } return $arrayType; }
public function testGetTypeName() { $this->assertEquals('array', Property::getArray('test')->getTypeName()); }
public function testVisitArrayNoPrototype() { $visitor = new AssimilationVisitor(); $property = Property::getArray('test'); $this->assertEquals(array(), $visitor->visitArray([], $property, '')); }