Example #1
0
 public function testToOptionHash()
 {
     $mockFirst = $this->getMock('Magento\\Framework\\DataObject', ['getSome', 'getId'], []);
     $mockFirst->expects($this->once())->method('getId')->will($this->returnValue(3));
     $mockFirst->expects($this->once())->method('getSome')->will($this->returnValue('code3'));
     $mockSecond = $this->getMock('Magento\\Framework\\DataObject', ['getSome', 'getId'], []);
     $mockSecond->expects($this->once())->method('getId')->will($this->returnValue(4));
     $mockSecond->expects($this->once())->method('getSome')->will($this->returnValue('code4'));
     $callable = function ($item) {
         return $item->getId();
     };
     $items = [$mockFirst, $mockSecond];
     $result = [3 => 'code3', 4 => 'code4'];
     $this->assertEquals($result, $this->model->toOptionHash($items, $callable, 'some'));
 }