/** * @param integer $id * @param string $url * @param bool $isAjax * @param string $expectedPostData * * @dataProvider deletePostJsonDataProvider * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ public function testGetDeletePostJson($id, $url, $isAjax, $expectedPostData) { $item = $this->getMock('Magento\\Quote\\Model\\Quote\\Item', [], [], '', false); $item->expects($this->once())->method('getId')->will($this->returnValue($id)); $this->requestMock->expects($this->once())->method('isAjax')->will($this->returnValue($isAjax)); $this->urlBuilderMock->expects($this->any())->method('getCurrentUrl')->will($this->returnValue($url)); $this->urlBuilderMock->expects($this->once())->method('getUrl')->will($this->returnValue($url)); $result = $this->helper->getDeletePostJson($item); $this->assertEquals($expectedPostData, $result); }
/** * Get delete item POST JSON * * @return string * @codeCoverageIgnore */ public function getDeletePostJson() { return $this->cartHelper->getDeletePostJson($this->getItem()); }
/** * @param integer $id * @param string $url * @param bool $isAjax * @param string $expectedPostData * * @dataProvider deletePostJsonDataProvider */ public function testGetDeletePostJson($id, $url, $isAjax, $expectedPostData) { $storeManager = $this->getMockForAbstractClass('\\Magento\\Store\\Model\\StoreManagerInterface'); $coreData = $this->getMock('\\Magento\\Core\\Helper\\Data', [], [], '', false); $scopeConfig = $this->getMockForAbstractClass('\\Magento\\Framework\\App\\Config\\ScopeConfigInterface'); $checkoutCart = $this->getMock('\\Magento\\Checkout\\Model\\Cart', [], [], '', false); $checkoutSession = $this->getMock('\\Magento\\Checkout\\Model\\Session', [], [], '', false); $context = $this->getMock('\\Magento\\Framework\\App\\Helper\\Context', [], [], '', false); $urlBuilder = $this->getMock('Magento\\Framework\\UrlInterface'); $context->expects($this->once())->method('getUrlBuilder')->will($this->returnValue($urlBuilder)); $item = $this->getMock('Magento\\Sales\\Model\\Quote\\Item', [], [], '', false); $request = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', [], [], '', false); $context->expects($this->once())->method('getRequest')->will($this->returnValue($request)); $helper = new Cart($context, $storeManager, $coreData, $scopeConfig, $checkoutCart, $checkoutSession); $item->expects($this->once())->method('getId')->will($this->returnValue($id)); $request->expects($this->once())->method('isAjax')->will($this->returnValue($isAjax)); $urlBuilder->expects($this->any())->method('getCurrentUrl')->will($this->returnValue($url)); $urlBuilder->expects($this->once())->method('getUrl')->will($this->returnValue($url)); $result = $helper->getDeletePostJson($item); $this->assertEquals($expectedPostData, $result); }