![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-review/Test/Unit/Model/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Review\Test\Unit\Model; use Magento\Framework\Event\ManagerInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; use Magento\Review\Model\ResourceModel\Review\Product\Collection; use Magento\Review\Model\Review; use Magento\Review\Model\ReviewFactory; use Magento\Review\Model\Rss; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class RssTest extends TestCase { /** * @var Rss */ protected $rss; /** * @var ObjectManagerHelper */ protected $objectManagerHelper; /** * @var ManagerInterface|MockObject */ protected $managerInterface; /** * @var MockObject */ protected $reviewFactory; protected function setUp(): void { $this->managerInterface = $this->getMockForAbstractClass(ManagerInterface::class); $this->reviewFactory = $this->createPartialMock(ReviewFactory::class, ['create']); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->rss = $this->objectManagerHelper->getObject( Rss::class, [ 'eventManager' => $this->managerInterface, 'reviewFactory' => $this->reviewFactory ] ); } public function testGetProductCollection() { $reviewModel = $this->createPartialMock(Review::class, [ '__wakeUp', 'getProductCollection' ]); $productCollection = $this->createPartialMock( Collection::class, [ 'addStatusFilter', 'addAttributeToSelect', 'setDateOrder' ] ); $reviewModel->expects($this->once())->method('getProductCollection') ->willReturn($productCollection); $this->reviewFactory->expects($this->once())->method('create')->willReturn($reviewModel); $productCollection->expects($this->once())->method('addStatusFilter')->willReturnSelf(); $productCollection->expects($this->once())->method('addAttributeToSelect')->willReturnSelf(); $productCollection->expects($this->once())->method('setDateOrder')->willReturnSelf(); $this->managerInterface->expects($this->once())->method('dispatch')->willReturnSelf(); $this->assertEquals($productCollection, $this->rss->getProductCollection()); } }