selectMock = $this->createPartialMock(\Magento\Framework\DB\Select::class, ['getPart']); $this->model = $objectManager->getObject(\Magento\Framework\DB\Select\DistinctRenderer::class); } public function testRenderNoPart() { $sql = 'SELECT'; $this->selectMock->expects($this->once()) ->method('getPart') ->with(Select::DISTINCT) ->willReturn(false); $this->assertEquals($sql, $this->model->render($this->selectMock, $sql)); } public function testRender() { $sql = 'SELECT'; $expectedResult = $sql . ' ' . Select::SQL_DISTINCT . ' '; $this->selectMock->expects($this->once()) ->method('getPart') ->with(Select::DISTINCT) ->willReturn(true); $this->assertEquals($expectedResult, $this->model->render($this->selectMock, $sql)); } }