public function testPrepareDataSource() { $dataSource = ['data' => ['items' => [['status_id' => 1]]]]; $expectedDataSource = ['data' => ['items' => [['status_id' => __('Approved')]]]]; $this->sourceMock->expects($this->once())->method('getReviewStatuses')->willReturn([\Magento\Review\Model\Review::STATUS_APPROVED => __('Approved')]); $this->assertEquals($expectedDataSource, $this->getModel()->prepareDataSource($dataSource)); }
protected function setUp() { $this->storeManager = $this->getMock('\\Magento\\Store\\Model\\StoreManagerInterface'); $this->requestMock = $this->getMock('\\Magento\\Framework\\App\\RequestInterface'); $this->reviewDataMock = $this->getMockBuilder('\\Magento\\Review\\Helper\\Data')->disableOriginalConstructor()->getMock(); $this->reviewDataMock->expects($this->once())->method('getIsGuestAllowToWrite')->willReturn(true); $this->context = $this->getMock('Magento\\Framework\\View\\Element\\Template\\Context', [], [], '', false); $this->context->expects($this->any())->method('getStoreManager')->will($this->returnValue($this->storeManager)); $this->context->expects($this->any())->method('getRequest')->willReturn($this->requestMock); $this->productRepository = $this->getMock('\\Magento\\Catalog\\Api\\ProductRepositoryInterface'); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->object = $this->objectManagerHelper->getObject('Magento\\Review\\Block\\Form', ['context' => $this->context, 'reviewData' => $this->reviewDataMock, 'productRepository' => $this->productRepository]); }