/**
  * @test
  * @author Christopher Hlubek <*****@*****.**>
  */
 public function entityReferencesReturnsSimpleAndArrayReferences()
 {
     $baseEntity = new \TYPO3\CouchDB\Tests\Functional\Fixtures\Domain\Model\TestEntity();
     $simpleReferencedEntity = new \TYPO3\CouchDB\Tests\Functional\Fixtures\Domain\Model\TestEntity();
     $baseEntity->setRelatedEntity($simpleReferencedEntity);
     $arrayReferencedEntity = new \TYPO3\CouchDB\Tests\Functional\Fixtures\Domain\Model\TestEntity();
     $relatedEntities = new \Doctrine\Common\Collections\ArrayCollection();
     $relatedEntities->add($arrayReferencedEntity);
     $relatedEntities->add($baseEntity);
     $baseEntity->setRelatedEntities($relatedEntities);
     $this->persistenceManager->add($baseEntity);
     $baseIdentifier = $this->persistenceManager->getIdentifierByObject($baseEntity);
     $simpleReferenceIdentifier = $this->persistenceManager->getIdentifierByObject($simpleReferencedEntity);
     $arrayReferenceIdentifier = $this->persistenceManager->getIdentifierByObject($arrayReferencedEntity);
     $this->persistenceManager->persistAll();
     $identifiers = $this->design->entityReferences($simpleReferenceIdentifier);
     $this->assertEquals(1, count($identifiers));
     $this->assertEquals($baseIdentifier, $identifiers[0]);
     $identifiers = $this->design->entityReferences($arrayReferenceIdentifier);
     $this->assertEquals(1, count($identifiers));
     $this->assertEquals($baseIdentifier, $identifiers[0]);
     $identifiers = $this->design->entityReferences($baseIdentifier);
     $this->assertEquals(0, count($identifiers));
 }
Example #2
0
 /**
  * @test
  * @author Christopher Hlubek <*****@*****.**>
  */
 public function updateMappedEntityWithCycle()
 {
     $repository = $this->objectManager->get('TYPO3\\CouchDB\\Tests\\Functional\\Fixtures\\Domain\\Repository\\TestEntityRepository');
     $entity = new \TYPO3\CouchDB\Tests\Functional\Fixtures\Domain\Model\TestEntity();
     $entity->setName('Foobar');
     $entity->setRelatedEntity($entity);
     $repository->add($entity);
     $identity = $this->persistenceManager->getIdentifierByObject($entity);
     $this->tearDown();
     $source = array('__identity' => $identity, 'name' => 'Foofoo');
     $propertyMapper = $this->objectManager->get('TYPO3\\Flow\\Property\\PropertyMapper');
     $mappedEntity = $propertyMapper->convert($source, 'TYPO3\\CouchDB\\Tests\\Functional\\Fixtures\\Domain\\Model\\TestEntity');
     $repository->update($mappedEntity);
     $this->assertEquals('Foofoo', $mappedEntity->getName());
 }