52 $this->contextMock = $this->createMock(\
Magento\Backend\Block\Template\Context::class);
53 $this->registryMock = $this->createMock(\
Magento\Framework\Registry::class);
54 $this->productMock = $this->createMock(\
Magento\Catalog\Model\Product::class);
55 $this->storeMock = $this->createMock(\
Magento\Store\Model\Store::class);
56 $this->storeManagerMock = $this->createMock(\
Magento\Store\Model\StoreManager::class);
57 $this->typeInstanceMock = $this->createMock(\
Magento\GroupedProduct\Model\Product\Type\Grouped::class);
59 $this->contextMock->expects(
64 $this->returnValue($this->storeManagerMock)
67 $this->priceCurrency = $this->getMockBuilder(
68 \
Magento\Framework\Pricing\PriceCurrencyInterface::class
71 $this->block = new \Magento\GroupedProduct\Block\Product\Grouped\AssociatedProducts\ListAssociatedProducts(
84 $this->priceCurrency->expects(
92 $this->returnValue(
'1')
95 $this->storeManagerMock->expects($this->any())->method(
'getStore')->will($this->returnValue($this->storeMock));
97 $this->productMock->expects(
102 $this->returnValue($this->typeInstanceMock)
105 $this->registryMock->expects(
112 $this->returnValue($this->productMock)
115 $this->typeInstanceMock->expects(
118 'getAssociatedProducts' 144 $this->assertEquals($expectedResult, $this->block->getAssociatedProducts());
155 $associatedProduct = $this->createPartialMock(
156 \
Magento\Framework\DataObject::class,
157 [
'getQty',
'getPosition',
'getId',
'getSku',
'getName',
'getPrice']
160 $associatedProduct->expects($this->once())->method(
'getId')->will($this->returnValue(
'id' . $productKey));
161 $associatedProduct->expects($this->once())->method(
'getSku')->will($this->returnValue(
'sku' . $productKey));
162 $associatedProduct->expects($this->once())->method(
'getName')->will($this->returnValue(
'name' . $productKey));
163 $associatedProduct->expects($this->once())->method(
'getQty')->will($this->returnValue($productKey));
164 $associatedProduct->expects($this->once())->method(
'getPosition')->will($this->returnValue($productKey));
165 $associatedProduct->expects($this->once())->method(
'getPrice')->will($this->returnValue(
'1.00'));
167 return $associatedProduct;
generateAssociatedProduct($productKey=0)
testGetAssociatedProducts()