public function testConvertToBuyRequest() { $optionId = 23; $optionValue = 'Option value'; $this->objectFactory->expects($this->once())->method('create')->willReturn($this->buyRequest); $this->cartItem->expects($this->any())->method('getProductOption')->willReturn($this->productOption); $this->productOption->expects($this->any())->method('getExtensionAttributes')->willReturn($this->extensibleAttribute); $this->extensibleAttribute->expects($this->atLeastOnce())->method('getCustomOptions')->willReturn([$this->customOption]); $this->customOption->expects($this->once())->method('getOptionId')->willReturn($optionId); $this->customOption->expects($this->once())->method('getOptionValue')->willReturn($optionValue); $this->assertSame($this->buyRequest, $this->processor->convertToBuyRequest($this->cartItem)); }
protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); $this->mathDivision = $this->getMock('\\Magento\\Framework\\Math\\Division', ['getExactDivision'], [], '', false); $this->localeFormat = $this->getMockForAbstractClass('\\Magento\\Framework\\Locale\\FormatInterface', ['getNumber']); $this->localeFormat->expects($this->any())->method('getNumber')->willReturn($this->qty); $this->object = $this->objectManagerHelper->getObject('Magento\\Framework\\DataObject'); $this->objectFactory = $this->getMock('\\Magento\\Framework\\DataObject\\Factory', ['create'], [], '', false); $this->objectFactory->expects($this->any())->method('create')->willReturn($this->object); $this->product = $this->getMock('Magento\\Catalog\\Model\\Product', ['load', 'isComposite', '__wakeup', 'isSaleable'], [], '', false); $this->productFactory = $this->getMock('Magento\\Catalog\\Model\\ProductFactory', ['create'], [], '', false); $this->productFactory->expects($this->any())->method('create')->willReturn($this->product); $this->stockStateProvider = $this->objectManagerHelper->getObject('Magento\\CatalogInventory\\Model\\StockStateProvider', ['mathDivision' => $this->mathDivision, 'localeFormat' => $this->localeFormat, 'objectFactory' => $this->objectFactory, 'productFactory' => $this->productFactory, 'qtyCheckApplicable' => $this->qtyCheckApplicable]); }