Exemplo n.º 1
0
 /**
  * @return array
  */
 protected function getItems()
 {
     $items = [];
     foreach ($this->helper->getItemCollection() as $item) {
         $items[] = ['id' => $item->getId(), 'product_url' => $this->productUrl->getUrl($item), 'name' => $this->outputHelper->productAttribute($item, $item->getName(), 'name'), 'remove_url' => $this->helper->getPostDataRemove($item)];
     }
     return $items;
 }
Exemplo n.º 2
0
 public function testGetPostDataRemove()
 {
     //Data
     $productId = 1;
     $removeUrl = 'catalog/product_compare/remove';
     $compareListUrl = 'catalog/product_compare';
     $postParams = array(\Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED => $this->compareHelper->urlEncode($compareListUrl), 'product' => $productId);
     //Verification
     $this->urlBuilder->expects($this->at(0))->method('getUrl')->with($compareListUrl)->will($this->returnValue($compareListUrl));
     $this->urlBuilder->expects($this->at(1))->method('getUrl')->with($removeUrl)->will($this->returnValue($removeUrl));
     $this->postDataHelper->expects($this->once())->method('getPostData')->with($removeUrl, $postParams)->will($this->returnValue(true));
     /** @var \Magento\Catalog\Model\Product | \PHPUnit_Framework_MockObject_MockObject $product */
     $product = $this->getMock('Magento\\Catalog\\Model\\Product', array('getId', '__wakeup'), array(), '', false);
     $product->expects($this->once())->method('getId')->will($this->returnValue($productId));
     $this->assertTrue($this->compareHelper->getPostDataRemove($product));
 }