/** * @return TemplateManager */ protected function getTemplateManager() { $entityRegistry = new TemplateEntityRegistry(); $templateManager = new TemplateManager($entityRegistry); $templateManager->addEntityRepository(new CountryFixture()); $templateManager->addEntityRepository(new RegionFixture()); $templateManager->addEntityRepository(new AddressTypeFixture()); $templateManager->addEntityRepository($this->fixture); return $templateManager; }
public function testGetData() { $templateManager = new TemplateManager(new TemplateEntityRegistry()); $templateManager->addEntityRepository(new EmptyFixture('\\stdClass')); $fixture = $templateManager->getEntityFixture('\\stdClass'); $data = $fixture->getData(); $this->assertCount(1, $data); $this->assertInstanceOf('\\stdClass', reset($data)); }
public function testGetEntityData() { $entityKey = 'test1'; $entity = new \stdClass(); $repository = $this->getMock('Oro\\Bundle\\ImportExportBundle\\TemplateFixture\\TemplateEntityRepositoryInterface'); $repository->expects($this->once())->method('getEntityClass')->will($this->returnValue(self::ENTITY_CLASS)); $this->templateManager->addEntityRepository($repository); $this->templateRepository->expects($this->once())->method('createEntity')->with($entityKey)->will($this->returnValue($entity)); $repository->expects($this->once())->method('fillEntityData')->with($entityKey, $this->identicalTo($entity)); // test that new entity is created $data = $this->callProtectedMethod($this->templateRepository, 'getEntityData', [$entityKey]); $data = iterator_to_array($data); $this->assertSame($entity, current($data)); $this->assertSame($entity, $this->entityRegistry->getEntity(self::ENTITY_CLASS, $entityKey)); // test that existing entity is returned $data = $this->callProtectedMethod($this->templateRepository, 'getEntityData', [$entityKey]); $data = iterator_to_array($data); $this->assertSame($entity, current($data)); $this->assertSame($entity, $this->entityRegistry->getEntity(self::ENTITY_CLASS, $entityKey)); }
public function testInitialization() { $repository = new TestTemplateEntityRepository(); $this->templateManager->addEntityRepository($repository); $this->assertSame($this->templateManager, $this->templateManager->getEntityRepository($repository->getEntityClass())->getTemplateManager()); }