15 use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
61 abstract protected function getModel();
66 $this->requestMock = $this->getMockBuilder(RequestInterface::class)
67 ->getMockForAbstractClass();
68 $this->productRepositoryMock = $this->getMockBuilder(ProductRepositoryInterface::class)
69 ->getMockForAbstractClass();
70 $this->productLinkRepositoryMock = $this->getMockBuilder(ProductLinkRepositoryInterface::class)
71 ->getMockForAbstractClass();
72 $this->productMock = $this->getMockBuilder(ProductInterface::class)
73 ->getMockForAbstractClass();
74 $this->collectionMock = $this->getMockBuilder(Collection::class)
75 ->disableOriginalConstructor()
77 $this->collectionFactoryMock = $this->getMockBuilder(CollectionFactory::class)
78 ->setMethods([
'create'])
79 ->disableOriginalConstructor()
82 $this->productRepositoryMock->expects($this->any())
84 ->willReturn($this->productMock);
85 $this->collectionFactoryMock->expects($this->once())
87 ->willReturn($this->collectionMock);
92 $this->collectionMock->expects($this->once())
93 ->method(
'addAttributeToFilter');
94 $this->productLinkRepositoryMock->expects($this->once())
97 $this->requestMock->expects($this->exactly(2))
101 $this->assertInstanceOf(Collection::class, $this->
getModel()->getCollection());