public function testGetArray() { $objectManager = $this->getMockBuilder(ObjectManager::class)->setMethods(['getRepository'])->disableOriginalConstructor()->getMock(); $options = $this->getMockBuilder(ModuleOptions::class)->disableOriginalConstructor()->getMock(); $repository = $this->getMockBuilder(EntityRepository::class)->setMethods(['findAll'])->disableOriginalConstructor()->getMock(); $entityClass = 'SiteConfigEntityClass'; $expectedResult = ['keyA' => 'valueA', 'keyB' => 'valueB', 'keyC' => 'valueC']; $dbResult = []; foreach ($expectedResult as $key => $value) { $entity = new SiteConfig(); $entity->setKey($key); $entity->setValue($value); $dbResult[] = $entity; } $options->expects($this->any())->method('getDoctrineORMEntityClass')->will($this->returnValue($entityClass)); $objectManager->expects($this->any())->method('getRepository')->with($entityClass)->will($this->returnValue($repository)); $repository->expects($this->once())->method('findAll')->will($this->returnValue($dbResult)); $reader = new DoctrineORMReader($objectManager, $options); $result = $reader->getArray(); $this->assertSame($expectedResult, $result); }
public function getArray() { $flat = parent::getArray(); return $this->unflatten($flat); }