/**
  * @test
  */
 public function embeddablesInsideClonedProxiedEntitiesAreCorrectlyLoaded()
 {
     $this->markTestSkipped('This is possibly a bug of Doctrine');
     $entity = new Fixtures\TestEntity();
     $entity->setName('Andi');
     $relatedEntity = new Fixtures\TestEntity();
     $relatedEntity->setName('Robert');
     $embedded = new Fixtures\TestEmbeddable('Foo');
     $relatedEntity->setEmbedded($embedded);
     $valueObject = new Fixtures\TestValueObject('Bar');
     $relatedEntity->setRelatedValueObject($valueObject);
     $entity->setRelatedEntity($relatedEntity);
     $clonedRelatedEntity = clone $entity->getRelatedEntity();
     $this->assertNotNull($clonedRelatedEntity->getEmbedded(), 'Unproxied clone embedded is null');
     $this->testEntityRepository->add($entity);
     $this->testEntityRepository->add($relatedEntity);
     $this->persistenceManager->persistAll();
     $this->persistenceManager->clearState();
     $entityIdentifier = $this->persistenceManager->getIdentifierByObject($entity);
     $loadedEntity = $this->testEntityRepository->findByIdentifier($entityIdentifier);
     $clonedRelatedEntity = clone $loadedEntity->getRelatedEntity();
     $this->assertNotNull($clonedRelatedEntity->getRelatedValueObject(), 'Proxied clone value object is null');
     $this->assertNotNull($clonedRelatedEntity->getEmbedded(), 'Proxied clone embedded is null');
     $this->assertEquals('Foo', $clonedRelatedEntity->getEmbedded()->getValue());
 }
Ejemplo n.º 2
0
 /**
  * @test
  */
 public function aopIsCorrectlyInitializedEvenIfADoctrineProxyGetsInitializedOnTheFlyFromTheOutside()
 {
     $entity = new Fixtures\TestEntity();
     $entity->setName('Andi');
     $relatedEntity = new Fixtures\TestEntity();
     $relatedEntity->setName('Robert');
     $entity->setRelatedEntity($relatedEntity);
     $this->testEntityRepository->add($entity);
     $this->testEntityRepository->add($relatedEntity);
     $this->persistenceManager->persistAll();
     $this->persistenceManager->clearState();
     $entityIdentifier = $this->persistenceManager->getIdentifierByObject($entity);
     $loadedEntity = $this->testEntityRepository->findByIdentifier($entityIdentifier);
     $this->testEntityRepository->findOneByName('Robert');
     $loadedRelatedEntity = $loadedEntity->getRelatedEntity();
     $this->assertEquals($loadedRelatedEntity->sayHello(), 'Hello Andi!');
 }