Example #1
0
 public function testAddOptionArray()
 {
     $optionCode = 1234;
     $optionData = ['product' => 'test', 'code' => $optionCode];
     $optionMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote\\Item\\Option')->setMethods(['setData', 'setItem', 'getCode', '__wakeup', 'isDeleted'])->disableOriginalConstructor()->getMock();
     $optionMock->expects($this->once())->method('setData')->with($optionData)->will($this->returnValue($optionMock));
     $optionMock->expects($this->once())->method('setItem')->with($this->model)->will($this->returnValue($optionMock));
     $optionMock->expects($this->exactly(3))->method('getCode')->will($this->returnValue($optionCode));
     $this->itemOptionFactory->expects($this->at(0))->method('create')->will($this->returnValue($optionMock));
     $this->model->addOption($optionData);
     $this->assertEquals([$optionMock], $this->model->getOptions());
     $this->assertEquals([$optionCode => $optionMock], $this->model->getOptionsByCode());
     $this->assertEquals($optionMock, $this->model->getOptionByCode($optionCode));
 }