Skip to content

Commit

Permalink
MAGETWO-82179: Fix Filter Customer Report Review 2.2-develop [Backport]
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksii Korshenko authored Oct 24, 2017
2 parents 1a35363 + db46f61 commit 6addbee
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,14 @@ protected function _joinCustomers()
*/
public function getSelectCountSql()
{
$countSelect = clone $this->_select;
$countSelect = clone $this->getSelect();
$countSelect->reset(\Magento\Framework\DB\Select::ORDER);
$countSelect->reset(\Magento\Framework\DB\Select::GROUP);
$countSelect->reset(\Magento\Framework\DB\Select::HAVING);
$countSelect->reset(\Magento\Framework\DB\Select::LIMIT_COUNT);
$countSelect->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET);
$countSelect->reset(\Magento\Framework\DB\Select::COLUMNS);
$countSelect->reset(\Magento\Framework\DB\Select::WHERE);

$countSelect->columns(new \Zend_Db_Expr('COUNT(DISTINCT detail.customer_id)'));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Reports\Model\ResourceModel\Review\Customer;

/**
* @magentoAppArea adminhtml
*/
class CollectionTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Reports\Model\ResourceModel\Review\Customer\Collection
*/
private $collection;

protected function setUp()
{
$this->collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Reports\Model\ResourceModel\Review\Customer\Collection::class
);
}

/**
* This tests covers issue described in:
* https://github.com/magento/magento2/issues/10301
*
* @magentoDataFixture Magento/Review/_files/customer_review.php
*/
public function testSelectCountSql()
{
$this->collection->addFieldToFilter('customer_name', ['like' => '%john%']);
$this->assertEquals(1, $this->collection->getSize());
}
}

0 comments on commit 6addbee

Please sign in to comment.