diff --git a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Image.php b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Image.php new file mode 100644 index 000000000..fcc905e90 --- /dev/null +++ b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Image.php @@ -0,0 +1,35 @@ + + * @Entity + */ +class DDC3597Image extends DDC3597Media { + + /** + * @var DDC3597Dimension + * @Embedded(class = "Doctrine\Tests\Models\DDC3597\Embeddable\DDC3597Dimension", columnPrefix = false) + */ + private $dimension; + + /** + * @param string $distributionHash + */ + function __construct($distributionHash) { + parent::__construct($distributionHash); + $this->dimension = new DDC3597Dimension(); + } + + /** + * @return DDC3597Dimension + */ + public function getDimension() { + return $this->dimension; + } +} \ No newline at end of file diff --git a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php new file mode 100644 index 000000000..07872431b --- /dev/null +++ b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php @@ -0,0 +1,74 @@ + + * @Entity + */ +abstract class DDC3597Media extends DDC3597Root { + + /** + * @var string + * + * @Column + */ + private $distributionHash; + + /** + * @var integer + * + * @Column + */ + private $size = 0; + + /** + * @var string + * @Column + */ + private $format; + + function __construct($distributionHash) { + $this->distributionHash = $distributionHash; + } + + /** + * @return string + */ + public function getDistributionHash() { + return $this->distributionHash; + } + + /** + * @return int + */ + public function getSize() { + return $this->size; + } + + /** + * @param int $size + */ + public function setSize($size) { + $this->size = $size; + } + + /** + * @return string + */ + public function getFormat() { + return $this->format; + } + + /** + * @param string $format + */ + public function setFormat($format) { + $this->format = $format; + } + + + +} \ No newline at end of file diff --git a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Root.php b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Root.php new file mode 100644 index 000000000..8c8228d5d --- /dev/null +++ b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Root.php @@ -0,0 +1,78 @@ +updatedAt = $this->createdAt = new \DateTime(); + } + + /** + * Set updatedAt + * + * @PreUpdate + */ + public function _preUpdate() { + $this->updatedAt = new \DateTime(); + } + + /** + * @return int + */ + public function getId() { + return (int)$this->id; + } + + + /** + * @return \DateTime + */ + public function getCreatedAt() { + return $this->createdAt; + } + + /** + * @return \DateTime + */ + public function getUpdatedAt() { + return $this->updatedAt; + } +} \ No newline at end of file diff --git a/tests/Doctrine/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php b/tests/Doctrine/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php new file mode 100644 index 000000000..cd5dc70a2 --- /dev/null +++ b/tests/Doctrine/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php @@ -0,0 +1,56 @@ +setWidth($width); + $this->setHeight($height); + } + + /** + * @return int + */ + public function getWidth() { + return $this->width; + } + + /** + * @param int $width + */ + public function setWidth($width) { + $this->width = (int)$width; + } + + /** + * @return int + */ + public function getHeight() { + return $this->height; + } + + /** + * @param int $height + */ + public function setHeight($height) { + $this->height = (int)$height; + } +} \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php new file mode 100644 index 000000000..65425184d --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php @@ -0,0 +1,54 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(DDC3597Root::class), + $this->_em->getClassMetadata(DDC3597Media::class), + $this->_em->getClassMetadata(DDC3597Image::class) + )); + } + + /** + * @group DDC-3597 + */ + public function testSaveImageEntity() { + $imageEntity = new DDC3597Image('foobar'); + $imageEntity->setFormat('JPG'); + $imageEntity->setSize(123); + $imageEntity->getDimension()->setWidth(300); + $imageEntity->getDimension()->setHeight(500); + + $this->_em->persist($imageEntity); + $this->_em->flush(); //before this fix, it will fail with a exception + + $this->_em->clear(); + + //request entity + $imageEntity = $this->_em->find(DDC3597Image::class, $imageEntity->getId()); + $this->assertInstanceOf(DDC3597Image::class, $imageEntity); + + //cleanup + $this->_em->remove($imageEntity); + $this->_em->flush(); + $this->_em->clear(); + + //check delete + $imageEntity = $this->_em->find(DDC3597Image::class, $imageEntity->getId()); + $this->assertNull($imageEntity); + } + +}