public function testGetCollection()
 {
     $this->collectionMock->expects($this->once())->method('addAttributeToFilter');
     $this->productLinkRepositoryMock->expects($this->once())->method('getList')->willReturn([]);
     $this->requestMock->expects($this->exactly(2))->method('getParam')->willReturn(1);
     $this->assertInstanceOf(Collection::class, $this->getModel()->getCollection());
 }
Пример #2
0
 protected function setUp()
 {
     $this->objectManager = new ObjectManager($this);
     $this->locatorMock = $this->getMockBuilder(LocatorInterface::class)->getMockForAbstractClass();
     $this->productMock = $this->getMockBuilder(ProductInterface::class)->setMethods(['getId', 'getTypeId'])->getMockForAbstractClass();
     $this->productMock->expects($this->any())->method('getId')->willReturn(self::PRODUCT_ID);
     $this->productMock->expects($this->any())->method('getTypeId')->willReturn(GroupedProductType::TYPE_CODE);
     $this->linkedProductMock = $this->getMockBuilder(ProductInterface::class)->setMethods(['getId', 'getName', 'getPrice'])->getMockForAbstractClass();
     $this->linkedProductMock->expects($this->any())->method('getId')->willReturn(self::LINKED_PRODUCT_ID);
     $this->linkedProductMock->expects($this->any())->method('getName')->willReturn(self::LINKED_PRODUCT_NAME);
     $this->linkedProductMock->expects($this->any())->method('getPrice')->willReturn(self::LINKED_PRODUCT_PRICE);
     $this->linkMock = $this->getMockBuilder(ProductLinkInterface::class)->setMethods(['getLinkType', 'getLinkedProductSku', 'getPosition', 'getExtensionAttributes'])->getMockForAbstractClass();
     $this->linkExtensionMock = $this->getMockBuilder(ProductLinkExtensionInterface::class)->setMethods(['getQty'])->getMockForAbstractClass();
     $this->linkExtensionMock->expects($this->any())->method('getQty')->willReturn(self::LINKED_PRODUCT_QTY);
     $this->linkMock->expects($this->any())->method('getExtensionAttributes')->willReturn($this->linkExtensionMock);
     $this->linkMock->expects($this->any())->method('getPosition')->willReturn(self::LINKED_PRODUCT_POSITION);
     $this->linkMock->expects($this->any())->method('getLinkedProductSku')->willReturn(self::LINKED_PRODUCT_SKU);
     $this->linkMock->expects($this->any())->method('getLinkType')->willReturn(Grouped::LINK_TYPE);
     $this->linkRepositoryMock = $this->getMockBuilder(ProductLinkRepositoryInterface::class)->setMethods(['getList'])->getMockForAbstractClass();
     $this->linkRepositoryMock->expects($this->any())->method('getList')->with($this->productMock)->willReturn([$this->linkMock]);
     $this->productRepositoryMock = $this->getMockBuilder(ProductRepositoryInterface::class)->setMethods(['get'])->getMockForAbstractClass();
     $this->productRepositoryMock->expects($this->any())->method('get')->with(self::LINKED_PRODUCT_SKU)->willReturn($this->linkedProductMock);
     $this->storeMock = $this->getMockBuilder(StoreInterface::class)->setMethods(['getId'])->getMockForAbstractClass();
     $this->locatorMock->expects($this->any())->method('getProduct')->willReturn($this->productMock);
     $this->locatorMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
 }