protected function parseString(array $data, $name) { $property = null; if (isset($data['format'])) { if ($data['format'] == 'date') { $property = Property::getDate($name); } elseif ($data['format'] == 'date-time') { $property = Property::getDateTime($name); } elseif ($data['format'] == 'duration') { $property = Property::getDuration($name); } elseif ($data['format'] == 'time') { $property = Property::getTime($name); } } if ($property === null) { $property = Property::getString($name); } $this->parseScalar($property, $data); return $property; }
public function testGetTypeName() { $this->assertEquals('duration', Property::getDuration('test')->getTypeName()); }
public function testVisitDurationDateTime() { $visitor = new ValidationVisitor(); $property = Property::getDuration('test'); $this->assertTrue($visitor->visitDuration(new \DateInterval('P1Y'), $property, '')); }
/** * @expectedException \PSX\Data\Schema\ValidationException */ public function testVisitDurationInvalidFormat() { $visitor = new AssimilationVisitor(); $property = Property::getDuration('test'); $visitor->visitDuration('foo', $property, ''); }