public function testAddProductWithoutSession() { /** @var $product \Magento\Catalog\Model\Product */ $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Product')->load(1); $this->_model->addProduct($product); $this->assertFalse($this->_model->hasItems(1, $this->_visitor->getId())); $this->assertTrue($this->_model->hasItems(0, $this->_visitor->getId())); }
public function testExecuteWithItems() { $this->request->expects($this->any())->method('getParam')->willReturnMap([['items', null, '1,2,3'], ['uenc', null, null]]); $this->decoderMock->expects($this->never())->method('decode'); $this->catalogSession->expects($this->never())->method('setBeforeCompareUrl'); $this->listCompareMock->expects($this->once())->method('addProducts')->with([1, 2, 3]); $redirect = $this->getMock('Magento\\Framework\\Controller\\Result\\Redirect', ['setPath'], [], '', false); $redirect->expects($this->once())->method('setPath')->with('*/*/*'); $this->redirectFactoryMock->expects($this->once())->method('create')->willReturn($redirect); $this->index->execute(); }