public function getOptions()
 {
     $this->product->expects($this->any())->method('getTypeInstance')->will($this->returnValue($this->productType));
     $this->product->expects($this->once())->method('getStoreId')->will($this->returnValue(1));
     $this->productType->expects($this->once())->method('setStoreFilter');
     $this->productType->expects($this->once())->method('getOptionsCollection')->with($this->equalTo($this->product))->will($this->returnValue($this->optionCollection));
     $this->productType->expects($this->once())->method('getOptionsIds')->with($this->equalTo($this->product))->will($this->returnValue([1, 2, 3]));
     $this->productType->expects($this->once())->method('getSelectionsCollection')->will($this->returnValue([]));
     $this->optionCollection->expects($this->any())->method('appendSelections')->with($this->equalTo([]))->will($this->returnValue([$this->option]));
 }
Пример #2
0
 /**
  * @expectedException \Magento\Framework\Exception\NoSuchEntityException
  */
 public function testGetNoSuchEntityException()
 {
     $productSku = 'oneSku';
     $optionId = 3;
     $this->productRepository->expects($this->once())->method('get')->with($this->equalTo($productSku))->will($this->returnValue($this->product));
     $this->product->expects($this->once())->method('getTypeId')->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE));
     $this->optionCollection->expects($this->once())->method('setIdFilter')->with($this->equalTo($optionId));
     $this->optionCollection->expects($this->once())->method('getFirstItem')->will($this->returnValue($this->optionModel));
     $this->productType->expects($this->once())->method('getOptionsCollection')->with($this->equalTo($this->product))->will($this->returnValue($this->optionCollection));
     $this->optionModel->expects($this->once())->method('getId');
     $this->model->get($productSku, $optionId);
 }
 public function testGetChildren()
 {
     $productSku = 'productSku';
     $this->getOptions();
     $this->productRepository->expects($this->any())->method('get')->with($this->equalTo($productSku))->will($this->returnValue($this->product));
     $this->product->expects($this->once())->method('getTypeId')->will($this->returnValue('bundle'));
     $this->productType->expects($this->once())->method('setStoreFilter')->with($this->equalTo($this->storeId), $this->product);
     $this->productType->expects($this->once())->method('getSelectionsCollection')->with($this->equalTo($this->optionIds), $this->equalTo($this->product))->will($this->returnValue($this->selectionCollection));
     $this->productType->expects($this->once())->method('getOptionsIds')->with($this->equalTo($this->product))->will($this->returnValue($this->optionIds));
     $this->optionCollection->expects($this->once())->method('appendSelections')->with($this->equalTo($this->selectionCollection))->will($this->returnValue([$this->option]));
     $this->option->expects($this->any())->method('getSelections')->will($this->returnValue([$this->product]));
     $this->linkConverter->expects($this->once())->method('createDataFromModel')->with($this->equalTo($this->product), $this->equalTo($this->product))->will($this->returnValue($this->link));
     $this->assertEquals([$this->link], $this->model->getChildren($productSku));
 }