Skip to content

Commit ba60d04

Browse files
committed
Add Unit tests for getSelectCountSql
1 parent bc5f8eb commit ba60d04

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

app/code/Magento/Reports/Model/ResourceModel/Review/Customer/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ protected function _joinCustomers()
106106
*/
107107
public function getSelectCountSql()
108108
{
109-
$countSelect = clone $this->_select;
109+
$countSelect = clone $this->getSelect();
110110
$countSelect->reset(\Magento\Framework\DB\Select::ORDER);
111111
$countSelect->reset(\Magento\Framework\DB\Select::GROUP);
112112
$countSelect->reset(\Magento\Framework\DB\Select::HAVING);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* CollectionTest
4+
*
5+
* @copyright Copyright (c) 2017 Interactiv4
6+
7+
*/
8+
9+
namespace Magento\Reports\Test\Unit\Model\ResourceModel\Review\Customer;
10+
11+
use Magento\Framework\DB\Select;
12+
use Magento\Reports\Model\ResourceModel\Review\Customer\Collection;
13+
14+
class CollectionTest extends \PHPUnit\Framework\TestCase
15+
{
16+
/**
17+
* @var \PHPUnit_Framework_MockObject_MockObject
18+
*/
19+
protected $selectMock;
20+
21+
protected function setUp()
22+
{
23+
$this->selectMock = $this->createMock(Select::class);
24+
}
25+
26+
public function testGetSelectCountSql()
27+
{
28+
/** @var $collection \PHPUnit_Framework_MockObject_MockObject */
29+
$collection = $this->getMockBuilder(Collection::class)
30+
->setMethods(['getSelect'])
31+
->disableOriginalConstructor()
32+
->getMock();
33+
34+
$collection->expects($this->atLeastOnce())->method('getSelect')->willReturn($this->selectMock);
35+
36+
$this->selectMock->expects($this->atLeastOnce())->method('reset')->willReturnSelf();
37+
$this->selectMock->expects($this->exactly(1))->method('columns')->willReturnSelf();
38+
39+
$this->assertEquals($this->selectMock, $collection->getSelectCountSql());
40+
}
41+
}

0 commit comments

Comments
 (0)