From 3574bb598ba1ef279fe45d61ee342c0fb4b192e0 Mon Sep 17 00:00:00 2001 From: Oscar Recio Date: Tue, 17 Oct 2017 20:10:53 +0200 Subject: [PATCH 1/5] Remove Where part from SelectCountSql --- .../Reports/Model/ResourceModel/Review/Customer/Collection.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Reports/Model/ResourceModel/Review/Customer/Collection.php b/app/code/Magento/Reports/Model/ResourceModel/Review/Customer/Collection.php index a832823967647..c25fe3c6508ed 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Review/Customer/Collection.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Review/Customer/Collection.php @@ -117,6 +117,7 @@ public function getSelectCountSql() $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)')); From 215d04d90dd7acfbd388abe5afddb7ded9cbbd67 Mon Sep 17 00:00:00 2001 From: Oscar Recio Date: Sat, 21 Oct 2017 01:45:55 +0200 Subject: [PATCH 2/5] Add Unit tests for getSelectCountSql --- .../Review/Customer/Collection.php | 2 +- .../Report/Review/Customer/CollectionTest.php | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Review/Customer/CollectionTest.php diff --git a/app/code/Magento/Reports/Model/ResourceModel/Review/Customer/Collection.php b/app/code/Magento/Reports/Model/ResourceModel/Review/Customer/Collection.php index c25fe3c6508ed..9297a1dda18d8 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Review/Customer/Collection.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Review/Customer/Collection.php @@ -110,7 +110,7 @@ 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); diff --git a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Review/Customer/CollectionTest.php b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Review/Customer/CollectionTest.php new file mode 100644 index 0000000000000..9534fe3b57f5a --- /dev/null +++ b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Review/Customer/CollectionTest.php @@ -0,0 +1,41 @@ +selectMock = $this->createMock(Select::class); + } + + public function testGetSelectCountSql() + { + /** @var $collection \PHPUnit_Framework_MockObject_MockObject */ + $collection = $this->getMockBuilder(Collection::class) + ->setMethods(['getSelect']) + ->disableOriginalConstructor() + ->getMock(); + + $collection->expects($this->atLeastOnce())->method('getSelect')->willReturn($this->selectMock); + + $this->selectMock->expects($this->atLeastOnce())->method('reset')->willReturnSelf(); + $this->selectMock->expects($this->exactly(1))->method('columns')->willReturnSelf(); + + $this->assertEquals($this->selectMock, $collection->getSelectCountSql()); + } +} From 3413f3edc1f17d7c7bfa16c6427d1602147868c3 Mon Sep 17 00:00:00 2001 From: Oscar Recio Date: Sun, 22 Oct 2017 17:56:52 +0200 Subject: [PATCH 3/5] Fix NameSpace --- .../ResourceModel/Report/Review/Customer/CollectionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Review/Customer/CollectionTest.php b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Review/Customer/CollectionTest.php index 9534fe3b57f5a..654742a0846e0 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Review/Customer/CollectionTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Review/Customer/CollectionTest.php @@ -6,7 +6,7 @@ * @author oscar.recio@interactiv4.com */ -namespace Magento\Reports\Test\Unit\Model\ResourceModel\Review\Customer; +namespace Magento\Reports\Test\Unit\Model\ResourceModel\Report\Review\Customer; use Magento\Framework\DB\Select; use Magento\Reports\Model\ResourceModel\Review\Customer\Collection; From 30ef797b9cd9140874f2823ac46ca394f5972ec6 Mon Sep 17 00:00:00 2001 From: Ievgen Shakhsuvarov Date: Tue, 24 Oct 2017 17:12:53 +0300 Subject: [PATCH 4/5] magento/magento2#11522: Fix Filter Customer Report Review - Integration test added --- .../Report/Review/Customer/CollectionTest.php | 41 ------------------- .../Review/Customer/CollectionTest.php | 36 ++++++++++++++++ 2 files changed, 36 insertions(+), 41 deletions(-) delete mode 100644 app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Review/Customer/CollectionTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Reports/Model/ResourceModel/Review/Customer/CollectionTest.php diff --git a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Review/Customer/CollectionTest.php b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Review/Customer/CollectionTest.php deleted file mode 100644 index 654742a0846e0..0000000000000 --- a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Report/Review/Customer/CollectionTest.php +++ /dev/null @@ -1,41 +0,0 @@ -selectMock = $this->createMock(Select::class); - } - - public function testGetSelectCountSql() - { - /** @var $collection \PHPUnit_Framework_MockObject_MockObject */ - $collection = $this->getMockBuilder(Collection::class) - ->setMethods(['getSelect']) - ->disableOriginalConstructor() - ->getMock(); - - $collection->expects($this->atLeastOnce())->method('getSelect')->willReturn($this->selectMock); - - $this->selectMock->expects($this->atLeastOnce())->method('reset')->willReturnSelf(); - $this->selectMock->expects($this->exactly(1))->method('columns')->willReturnSelf(); - - $this->assertEquals($this->selectMock, $collection->getSelectCountSql()); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Reports/Model/ResourceModel/Review/Customer/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Reports/Model/ResourceModel/Review/Customer/CollectionTest.php new file mode 100644 index 0000000000000..25d16235603bf --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Reports/Model/ResourceModel/Review/Customer/CollectionTest.php @@ -0,0 +1,36 @@ +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()); + } +} From 02f9bd5613ad3a450077efffad5cffa29ccfe0b7 Mon Sep 17 00:00:00 2001 From: Ievgen Shakhsuvarov Date: Tue, 24 Oct 2017 17:26:09 +0300 Subject: [PATCH 5/5] magento/magento2#11522: Fix Filter Customer Report Review - Integration test updated --- .../Model/ResourceModel/Review/Customer/CollectionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Reports/Model/ResourceModel/Review/Customer/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Reports/Model/ResourceModel/Review/Customer/CollectionTest.php index 25d16235603bf..2decae1acf9ac 100644 --- a/dev/tests/integration/testsuite/Magento/Reports/Model/ResourceModel/Review/Customer/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Reports/Model/ResourceModel/Review/Customer/CollectionTest.php @@ -3,7 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Reports\Model\ResourceModel\Review\Product; +namespace Magento\Reports\Model\ResourceModel\Review\Customer; /** * @magentoAppArea adminhtml