managerInterface = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); $this->reviewFactory = $this->createPartialMock(\Magento\Review\Model\ReviewFactory::class, ['create']); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->rss = $this->objectManagerHelper->getObject( \Magento\Review\Model\Rss::class, [ 'eventManager' => $this->managerInterface, 'reviewFactory' => $this->reviewFactory ] ); } public function testGetProductCollection() { $reviewModel = $this->createPartialMock(\Magento\Review\Model\Review::class, [ '__wakeUp', 'getProductCollection' ]); $productCollection = $this->createPartialMock( \Magento\Review\Model\ResourceModel\Review\Product\Collection::class, [ 'addStatusFilter', 'addAttributeToSelect', 'setDateOrder' ] ); $reviewModel->expects($this->once())->method('getProductCollection') ->will($this->returnValue($productCollection)); $this->reviewFactory->expects($this->once())->method('create')->will($this->returnValue($reviewModel)); $productCollection->expects($this->once())->method('addStatusFilter')->will($this->returnSelf()); $productCollection->expects($this->once())->method('addAttributeToSelect')->will($this->returnSelf()); $productCollection->expects($this->once())->method('setDateOrder')->will($this->returnSelf()); $this->managerInterface->expects($this->once())->method('dispatch')->will($this->returnSelf()); $this->assertEquals($productCollection, $this->rss->getProductCollection()); } }