Exemplo n.º 1
0
 public function testToOptionHash()
 {
     $data = [10 => 'test'];
     $adapterMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', ['select', 'query'], [], '', false);
     $selectMock = $this->getMock('Magento\\Framework\\DB\\Select', [], ['adapter' => $adapterMock]);
     $adapterMock->expects($this->once())->method('select')->will($this->returnValue($selectMock));
     $this->fetchStrategyMock->expects($this->once())->method('fetchAll')->with($selectMock, [])->will($this->returnValue([$data]));
     $objectMock = $this->getMock('Magento\\Framework\\DataObject', ['addData', 'setIdFieldName', 'getData'], []);
     $objectMock->expects($this->once())->method('addData')->with($data);
     $objectMock->expects($this->any())->method('getData')->will($this->returnValueMap([[null, null, 10], ['name', null, 'test']]));
     $this->entityFactoryMock->expects($this->once())->method('create')->with('Magento\\Framework\\DataObject')->will($this->returnValue($objectMock));
     $this->collection->setConnection($adapterMock);
     $this->collection->loadData(false, false);
     $this->collection->loadData(false, false);
     $this->assertEquals($data, $this->collection->toOptionHash());
 }