/**
  * Creates metadata for testing.
  *
  * @param LoggerInterface|null $logger
  * @return TranslationMetadata
  */
 private function createMetadata(LoggerInterface $logger = null)
 {
     $reader = new AnnotationReader();
     $infrastructure = new ORMInfrastructure(array('\\Webfactory\\Bundle\\PolyglotBundle\\Tests\\TestEntity', '\\Webfactory\\Bundle\\PolyglotBundle\\Tests\\TestEntityTranslation'));
     $metadata = $infrastructure->getEntityManager()->getClassMetadata('Webfactory\\Bundle\\PolyglotBundle\\Tests\\TestEntity');
     $translationMetadata = TranslationMetadata::parseFromClassMetadata($metadata, $reader);
     if ($logger !== null) {
         $translationMetadata->setLogger($logger);
     }
     return $translationMetadata;
 }
 /**
  * @param TestEntity $entity
  * @param string $expectedText
  */
 private function assertTextInReloadedEntityEquals(TestEntity $entity, $expectedText)
 {
     /* @var $reloadedEntity TestEntity */
     $reloadedEntity = $this->infrastructure->getRepository($entity)->find($entity->getId());
     $loadedText = $reloadedEntity->getText();
     $this->assertInstanceOf('\\Webfactory\\Bundle\\PolyglotBundle\\TranslatableInterface', $loadedText);
     $this->assertSame($expectedText, $loadedText->__toString());
 }
 /**
  * Ensures that the infrastructure logs queries, which are executed after an import.
  */
 public function testInfrastructureLogsQueriesThatAreExecutedAfterImport()
 {
     $entity = new TestEntity();
     $this->infrastructure->import($entity);
     $repository = $this->infrastructure->getRepository($entity);
     $repository->find(42);
     $queries = $this->infrastructure->getQueries();
     $this->assertInternalType('array', $queries);
     $this->assertCount(1, $queries);
 }
 /**
  * Ensures that it is not possible to retrieve the class names of entities,
  * which are not simulated by the infrastructure.
  *
  * If not handled properly, the metadata provides access to several entity classes.
  */
 public function testNotSimulatedEntitiesAreNotExposed()
 {
     $infrastructure = ORMInfrastructure::createOnlyFor(array('\\Webfactory\\Doctrine\\ORMTestInfrastructure\\ORMInfrastructureTest\\TestEntity'));
     $metadata = $infrastructure->getEntityManager()->getMetadataFactory()->getAllMetadata();
     $entities = array_map(function (ClassMetadataInfo $info) {
         return ltrim($info->name, '\\');
     }, $metadata);
     $this->assertEquals(array('Webfactory\\Doctrine\\ORMTestInfrastructure\\ORMInfrastructureTest\\TestEntity'), $entities);
 }
 /**
  * @iterations 100
  */
 public function complexEntityWithExplicitAssociationDefinition()
 {
     $infrastructure = ORMInfrastructure::createOnlyFor(array('\\Webfactory\\Doctrine\\ORMTestInfrastructure\\ORMInfrastructureTest\\ChainReferenceEntity', '\\Webfactory\\Doctrine\\ORMTestInfrastructure\\ORMInfrastructureTest\\TestEntityWithDependency', '\\Webfactory\\Doctrine\\ORMTestInfrastructure\\ORMInfrastructureTest\\ReferencedEntity'));
     $infrastructure->getEntityManager();
 }
 /**
  * @iterations 200
  */
 public function import100EntitiesReturnedByPhpFile()
 {
     $this->infrastructure->import($this->getImportFilePath('return-100-entities.php'));
 }