Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.2-develop] Fix Filter Customer Report Review #11522

Merged
merged 6 commits into from
Oct 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}