示例#1
0
 /**
  * @test
  */
 public function aopIsCorrectlyInitializedEvenIfADoctrineProxyGetsInitializedOnTheFlyFromTheOutside()
 {
     $entity = new TestEntity();
     $entity->setName('Andi');
     $relatedEntity = new 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!');
 }
示例#2
0
 /**
  * Helper which inserts example data into the database.
  *
  * @param string $name
  */
 protected function insertExampleEntity($name = 'FLOW3')
 {
     $testEntity = new TestEntity();
     $testEntity->setName($name);
     $this->testEntityRepository->add($testEntity);
     $this->persistenceManager->persistAll();
     $this->persistenceManager->clearState();
 }