public function testProcessCustomOptions() { $optionId = 23; $quoteItemOption = $this->getMockBuilder('Magento\\Quote\\Model\\Quote\\Item\\Option')->disableOriginalConstructor()->getMock(); $this->cartItem->expects($this->atLeastOnce())->method('getOptionByCode')->with('info_buyRequest')->willReturn($quoteItemOption); $quoteItemOption->expects($this->once())->method('getValue')->willReturn('a:1:{s:7:"options";a:1:{i:' . $optionId . ';a:2:{i:0;s:1:"5";i:1;s:1:"6";}}} '); $this->customOptionFactory->expects($this->once())->method('create')->willReturn($this->customOption); $this->customOption->expects($this->once())->method('setOptionId')->with($optionId); $this->customOption->expects($this->once())->method('setOptionValue')->with('5,6'); $this->cartItem->expects($this->atLeastOnce())->method('getProductOption')->willReturn(false); $this->productOptionFactory->expects($this->once())->method('create')->willReturn($this->productOption); $this->productOption->expects($this->once())->method('getExtensionAttributes')->willReturn(false); $this->extensionFactory->expects($this->once())->method('create')->willReturn($this->extensibleAttribute); $this->extensibleAttribute->expects($this->once())->method('setCustomOptions')->with([$optionId => $this->customOption]); $this->productOption->expects($this->once())->method('setExtensionAttributes')->with($this->extensibleAttribute); $this->cartItem->expects($this->once())->method('setProductOption')->with($this->productOption); $this->assertSame($this->cartItem, $this->processor->processOptions($this->cartItem)); }
public function testSetOptionValue() { $this->model->setOptionValue('test'); $this->assertEquals('test', $this->model->getOptionValue()); }