public function testArray() { $photo = new Photo(); $photo->setNom('wohoo'); $serialized = $this->type->convertToDatabaseValue([$photo], $this->plateform); $unserialized = $this->type->convertToPHPValue($serialized, $this->plateform); $this->assertInstanceOf(Photo::class, $unserialized[0]); /** @var Photo $var */ $var = $unserialized[0]; $this->assertEquals('wohoo', $var->getNom()); }
public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null) { return null; } try { return parent::convertToPHPValue($value, $platform); } catch (ConversionException $e) { $val = \DateTime::createFromFormat('Y-m-d H:i:s.uO', $value); if (!$val) { throw ConversionException::conversionFailedFormat($value, $this->getName(), 'Y-m-d H:i:s.uO'); } return $val; } }
/** * @dataProvider sqlValueProvider */ public function testConversionToPHP($sql, $expected) { $value = $this->type->convertToPHPValue($sql, $this->platform); $this->assertEquals($expected, $value); }
public function testReturnValueIfUuidForPHPValue() { $uuid = Uuid::uuid4(); $this->assertSame($uuid, $this->type->convertToPHPValue($uuid, $this->platform)); }
private function value(EntityManager $em, Type $type, $value) { $platform = $em->getConnection()->getDatabasePlatform(); switch ($type->getName()) { case Type::BOOLEAN: return $type->convertToPHPValue($value, $platform); // json supports boolean values // json supports boolean values default: return $type->convertToDatabaseValue($value, $platform); } }