Пример #1
0
 /**
  * @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, '');
 }
Пример #2
0
 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;
 }
Пример #3
0
 public function testGetTypeName()
 {
     $this->assertEquals('array', Property::getArray('test')->getTypeName());
 }
Пример #4
0
 public function testVisitArrayNoPrototype()
 {
     $visitor = new AssimilationVisitor();
     $property = Property::getArray('test');
     $this->assertEquals(array(), $visitor->visitArray([], $property, ''));
 }