private function hydrateField(DataTransferObject $dto, array $dataset, $fieldName, Field $field) { if (!property_exists($dto, $fieldName)) { throw new InvalidDataException(sprintf('Field "%s" does not exist in DataTransferObject class "%s".', $fieldName, get_class($dto))); } $value = $this->findValue($field->getNamePath(), $dataset); $value = $field->convert($value); $dto->{$fieldName} = $this->transformValue($field, $value); }
/** * @dataProvider providerTestConvertWithExceptions * @expectedException \Spear\Silex\Persistence\Exceptions\InvalidDataException */ public function testConvertWithExceptions(Field $field, $value) { $field->convert($value); }
/** * @dataProvider providerTestConvert */ public function testConvert(Field $field, $value, $expected) { $convertedValue = $field->convert($value); $this->assertSame($expected, $convertedValue); }