-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix count SQL on products sold collection
- Loading branch information
James Halsall
committed
Mar 16, 2017
1 parent
3f75fac
commit dc333b4
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
.../Magento/Reports/Test/Unit/Model/ResourceModel/Product/Sold/Collection/CollectionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Magento\Reports\Test\Unit\Model\ResourceModel\Product\Sold\Collection; | ||
|
||
use Magento\Framework\DB\Select; | ||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
use Magento\Reports\Model\ResourceModel\Product\Sold\Collection; | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) | ||
*/ | ||
class CollectionTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var ObjectManager | ||
*/ | ||
protected $objectManager; | ||
|
||
/** | ||
* @var \PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $selectMock; | ||
|
||
protected function setUp() | ||
{ | ||
$this->objectManager = new ObjectManager($this); | ||
$this->selectMock = $this->getMock(Select::class, [], [], '', false); | ||
} | ||
|
||
public function testGetSelectCountSql() | ||
{ | ||
/** @var $collection \PHPUnit_Framework_MockObject_MockObject */ | ||
$constructArgs = $this->objectManager->getConstructArguments(Collection::class); | ||
$collection = $this->getMock(Collection::class, ['getSelect'], $constructArgs, '', false); | ||
|
||
$collection->expects($this->atLeastOnce())->method('getSelect')->willReturn($this->selectMock); | ||
|
||
$this->selectMock->expects($this->atLeastOnce())->method('reset')->willReturnSelf(); | ||
$this->selectMock->expects($this->exactly(2))->method('columns')->willReturnSelf(); | ||
|
||
$this->selectMock->expects($this->at(6))->method('columns')->with('COUNT(DISTINCT main_table.entity_id)'); | ||
|
||
$this->selectMock->expects($this->at(7))->method('reset')->with(Select::COLUMNS); | ||
$this->selectMock->expects($this->at(8))->method('columns')->with('COUNT(DISTINCT order_items.item_id)'); | ||
|
||
$this->assertEquals($this->selectMock, $collection->getSelectCountSql()); | ||
} | ||
} |