From fb9892b5f51f72f6dcf4a520a50de0e08994c4c7 Mon Sep 17 00:00:00 2001 From: Vasek Purchart Date: Wed, 13 Sep 2017 10:28:28 +0200 Subject: [PATCH] test for combination of partials and not loaded embedables --- tests/Enum/LoadEnumToEntityIntegrationTest.php | 8 ++++++++ tests/Enum/data/FooEntity.php | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/tests/Enum/LoadEnumToEntityIntegrationTest.php b/tests/Enum/LoadEnumToEntityIntegrationTest.php index ccaaf60..9fa265a 100644 --- a/tests/Enum/LoadEnumToEntityIntegrationTest.php +++ b/tests/Enum/LoadEnumToEntityIntegrationTest.php @@ -60,6 +60,14 @@ public function testLoadEnumInEmbeddableWeNeedToGoDeeper() $this->assertSame(FooEnum::get(FooEnum::ONE), $foo->getEmbedded()->getEmbedded()->getEnum()); } + public function testLoadEnumInNotLoadedEmbeddable() + { + $foo = new FooEntity(); + $this->callPostLoadEventOnEntity($foo); + + $this->assertNull($foo->getNotLoadedEmbedded()); + } + public function testLoadEnumMissingEnumClass() { $this->expectException(\Doctrine\Common\Annotations\AnnotationException::class); diff --git a/tests/Enum/data/FooEntity.php b/tests/Enum/data/FooEntity.php index 2e0993e..1431ded 100644 --- a/tests/Enum/data/FooEntity.php +++ b/tests/Enum/data/FooEntity.php @@ -40,6 +40,14 @@ class FooEntity extends \Consistence\Doctrine\Enum\FooParentEntity */ private $embedded; + /** + * This simulates for example using partials where this was not selected + * + * @ORM\Embedded(class=FooEmbeddable::class, columnPrefix="not_loaded_") + * @var \Consistence\Doctrine\Enum\FooEmbeddable + */ + private $notLoadedEmbedded; + public function __construct() { $this->embedded = new FooEmbeddable(); @@ -68,4 +76,12 @@ public function getEmbedded(): FooEmbeddable return $this->embedded; } + /** + * @return \Consistence\Doctrine\Enum\FooEmbeddable + */ + public function getNotLoadedEmbedded() + { + return $this->notLoadedEmbedded; + } + }