Exemple #1
0
 /**
  * @expectedException \Magento\Framework\Exception\NoSuchEntityException
  */
 public function testLoadNoSuchEntityException()
 {
     $categoryId = 333;
     $this->category->expects($this->once())->method('load')->with($this->equalTo($categoryId));
     $this->category->expects($this->once())->method('getId')->will($this->returnValue(false));
     $this->model->load($categoryId);
 }
 private function prepareMocksForAssign($categoryId, $productId = 333)
 {
     $productSku = 'sku333';
     $productsPosition = [105 => 16, 334 => 1];
     $this->productLink->expects($this->once())->method('getSku')->will($this->returnValue($productSku));
     $this->productLink->expects($this->any())->method('getPosition')->will($this->returnValue($categoryId));
     $this->categoryLoader->expects($this->once())->method('load')->with($this->equalTo($categoryId))->will($this->returnValue($this->category));
     $this->category->expects($this->once())->method('getProductsPosition')->will($this->returnValue($productsPosition));
     $newProductPositions = [$productId => $categoryId] + $productsPosition;
     $this->category->expects($this->any())->method('setPostedProducts')->with($this->equalTo($newProductPositions));
     $this->product->expects($this->once())->method('getIdBySku')->with($this->equalTo($productSku))->will($this->returnValue($productId));
 }