From 9182ca9991a5c9d2fc1ccce89cc5729450dc9594 Mon Sep 17 00:00:00 2001 From: Ruslan Kostiv Date: Mon, 25 Sep 2017 13:09:03 +0300 Subject: [PATCH 01/23] MAGETWO-72597: [2.2.x] - Impossible to perform mass update on product with 60+ attributes in system --- .../Entity/Attribute/Collection.php | 24 +-- .../Entity/Attribute/CollectionTest.php | 159 ++++++++++++++++++ 2 files changed, 172 insertions(+), 11 deletions(-) create mode 100644 app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/CollectionTest.php diff --git a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Collection.php b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Collection.php index 872a9b79c9ba6..c1f693b92d2a1 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Collection.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Collection.php @@ -210,17 +210,19 @@ public function setAttributeSetsFilter(array $setIds) */ public function setInAllAttributeSetsFilter(array $setIds) { - foreach ($setIds as $setId) { - $setId = (int)$setId; - if (!$setId) { - continue; - } - $alias = sprintf('entity_attribute_%d', $setId); - $joinCondition = $this->getConnection()->quoteInto( - "{$alias}.attribute_id = main_table.attribute_id AND {$alias}.attribute_set_id =?", - $setId - ); - $this->join([$alias => 'eav_entity_attribute'], $joinCondition, 'attribute_id'); + if (!empty($setIds)) { + $this->getSelect() + ->join( + ['entity_attribute' => $this->getTable('eav_entity_attribute')], + 'entity_attribute.attribute_id = main_table.attribute_id', + ['count' => new \Zend_Db_Expr('COUNT(*)')] + ) + ->where( + 'entity_attribute.attribute_set_id IN (?)', + $setIds + ) + ->group('entity_attribute.attribute_id') + ->having('count = ' . count($setIds)); } //$this->getSelect()->distinct(true); diff --git a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/CollectionTest.php b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/CollectionTest.php new file mode 100644 index 0000000000000..c1a94a7ca4a50 --- /dev/null +++ b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/CollectionTest.php @@ -0,0 +1,159 @@ +entityFactoryMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\EntityFactory::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->fetchStrategyMock = $this->getMockBuilder(FetchStrategyInterface::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->eventManagerMock = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->eavConfigMock = $this->getMockBuilder(\Magento\Eav\Model\Config::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->resourceMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class) + ->setMethods(['__wakeup', 'getConnection', 'getMainTable', 'getTable']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock); + $this->resourceMock->expects($this->any())->method('getMainTable')->willReturn('eav_entity_attribute'); + + $this->selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->connectionMock->expects($this->any())->method('select')->willReturn($this->selectMock); + + $objectManager = new ObjectManager($this); + $this->model = $objectManager->getObject( + \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection::class, + [ + 'entityFactory' => $this->entityFactoryMock, + 'logger' => $this->loggerMock, + 'fetchStrategy' => $this->fetchStrategyMock, + 'eventManager' => $this->eventManagerMock, + 'eavConfig' => $this->eavConfigMock, + 'connection' => $this->connectionMock, + 'resource' => $this->resourceMock, + ] + ); + } + + /** + * Test method \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection::setInAllAttributeSetsFilter + * + * @return void + */ + public function testSetInAllAttributeSetsFilter() + { + $setIds = [1, 2, 3]; + + $this->selectMock->expects($this->atLeastOnce()) + ->method('where') + ->with('entity_attribute.attribute_set_id IN (?)', $setIds) + ->willReturnSelf(); + $this->selectMock->expects($this->atLeastOnce())->method('join')->with( + ['entity_attribute' => $this->model->getTable('eav_entity_attribute')], + 'entity_attribute.attribute_id = main_table.attribute_id', + ['count' => new \Zend_Db_Expr('COUNT(*)')] + )->willReturnSelf(); + + $this->selectMock->expects($this->atLeastOnce())->method('group')->with('entity_attribute.attribute_id') + ->willReturnSelf(); + + $this->selectMock->expects($this->atLeastOnce())->method('having')->with('count = ' . count($setIds)) + ->willReturnSelf(); + + $this->model->setInAllAttributeSetsFilter($setIds); + } +} From 04a81b79aa79ffd60f9cd0e1f6432d0a9298aa6f Mon Sep 17 00:00:00 2001 From: Michail Slabko Date: Fri, 17 Nov 2017 15:28:38 +0200 Subject: [PATCH 02/23] MAGETWO-73696: Sorting by price column in admin doesn't count disabled products --- .../Product/ProductCollection.php | 28 +++++++++++++++++++ app/code/Magento/Catalog/etc/adminhtml/di.xml | 6 ++++ 2 files changed, 34 insertions(+) create mode 100644 app/code/Magento/Catalog/Ui/DataProvider/Product/ProductCollection.php diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductCollection.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductCollection.php new file mode 100644 index 0000000000000..ca6855af9e7f1 --- /dev/null +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductCollection.php @@ -0,0 +1,28 @@ +_productLimitationFilters->setUsePriceIndex(false); + return $this->_productLimitationPrice(true); + } +} diff --git a/app/code/Magento/Catalog/etc/adminhtml/di.xml b/app/code/Magento/Catalog/etc/adminhtml/di.xml index 790bd163a6f17..570b6b21d5b2c 100644 --- a/app/code/Magento/Catalog/etc/adminhtml/di.xml +++ b/app/code/Magento/Catalog/etc/adminhtml/di.xml @@ -78,6 +78,11 @@ + + + \Magento\Catalog\Ui\DataProvider\Product\ProductCollection + + @@ -86,6 +91,7 @@ Magento\Catalog\Ui\DataProvider\Product\AddStoreFieldToCollection + \Magento\Catalog\Ui\DataProvider\Product\ProductCollectionFactory From 7e46ab06b2b2c9f24455be56a1d0b542c5dbda20 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Tue, 23 Jan 2018 11:26:35 +0200 Subject: [PATCH 03/23] MAGETWO-84967: Set auto increment to 3 for Performance test plan --- .../Setup/Fixtures/_files/orders_fixture_data.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup/src/Magento/Setup/Fixtures/_files/orders_fixture_data.json b/setup/src/Magento/Setup/Fixtures/_files/orders_fixture_data.json index 864ad45533afe..33aa883ed5253 100644 --- a/setup/src/Magento/Setup/Fixtures/_files/orders_fixture_data.json +++ b/setup/src/Magento/Setup/Fixtures/_files/orders_fixture_data.json @@ -102,7 +102,7 @@ "weight": 2.0000, "customer_dob": "NULL", "increment_id": "'%orderNumber%'", - "applied_rule_ids": 1, + "applied_rule_ids": 3, "base_currency_code": "'USD'", "customer_email": "'%email%'", "customer_firstname": "NULL", @@ -208,7 +208,7 @@ "sku": "'%sku%'", "name": "'%name%'", "description": "NULL", - "applied_rule_ids": "'1'", + "applied_rule_ids": "'3'", "additional_data": "NULL", "is_qty_decimal": "'0'", "no_discount": "'0'", @@ -374,7 +374,7 @@ "customer_note_notify": 1, "customer_is_guest": 1, "remote_ip": "'127.0.0.1'", - "applied_rule_ids": "'1'", + "applied_rule_ids": "'3'", "reserved_order_id": "NULL", "password_hash": "NULL", "coupon_code": "NULL", @@ -512,7 +512,7 @@ "sku": "'%sku%'", "name": "'%name%'", "description": "NULL", - "applied_rule_ids": "'1'", + "applied_rule_ids": "'3'", "additional_data": "NULL", "is_qty_decimal": "0", "no_discount": "0", From 6554d2fd8972f32c8bb1bc17e6194d614cf7e5e0 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Tue, 23 Jan 2018 17:06:37 +0200 Subject: [PATCH 04/23] MAGETWO-84967: Set auto increment to 3 for Performance test plan --- setup/src/Magento/Setup/Fixtures/OrdersFixture.php | 7 +++++++ .../Setup/Fixtures/_files/orders_fixture_data.json | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/setup/src/Magento/Setup/Fixtures/OrdersFixture.php b/setup/src/Magento/Setup/Fixtures/OrdersFixture.php index 74ff84189f557..1acad6dbc1787 100644 --- a/setup/src/Magento/Setup/Fixtures/OrdersFixture.php +++ b/setup/src/Magento/Setup/Fixtures/OrdersFixture.php @@ -232,6 +232,12 @@ public function execute() return; } + $ruleId = $this->getMaxEntityId( + 'salesrule', + \Magento\SalesRule\Model\ResourceModel\Rule::class, + 'rule_id' + ); + $maxItemId = $this->getMaxEntityId( 'sales_order_item', \Magento\Sales\Model\ResourceModel\Order\Item::class, @@ -330,6 +336,7 @@ public function execute() '%productStoreId%' => $productStoreId($entityId), '%productStoreName%' => $productStoreName($entityId), '%entityId%' => $entityId, + '%ruleId%' => $ruleId, ]; $shippingAddress = ['%orderAddressId%' => $entityId * 2 - 1, '%addressType%' => 'shipping']; $billingAddress = ['%orderAddressId%' => $entityId * 2, '%addressType%' => 'billing']; diff --git a/setup/src/Magento/Setup/Fixtures/_files/orders_fixture_data.json b/setup/src/Magento/Setup/Fixtures/_files/orders_fixture_data.json index 33aa883ed5253..29b1a56fe6d6e 100644 --- a/setup/src/Magento/Setup/Fixtures/_files/orders_fixture_data.json +++ b/setup/src/Magento/Setup/Fixtures/_files/orders_fixture_data.json @@ -102,7 +102,7 @@ "weight": 2.0000, "customer_dob": "NULL", "increment_id": "'%orderNumber%'", - "applied_rule_ids": 3, + "applied_rule_ids": "%rule_id%", "base_currency_code": "'USD'", "customer_email": "'%email%'", "customer_firstname": "NULL", @@ -208,7 +208,7 @@ "sku": "'%sku%'", "name": "'%name%'", "description": "NULL", - "applied_rule_ids": "'3'", + "applied_rule_ids": "'%ruleId%'", "additional_data": "NULL", "is_qty_decimal": "'0'", "no_discount": "'0'", @@ -374,7 +374,7 @@ "customer_note_notify": 1, "customer_is_guest": 1, "remote_ip": "'127.0.0.1'", - "applied_rule_ids": "'3'", + "applied_rule_ids": "'%ruleId%'", "reserved_order_id": "NULL", "password_hash": "NULL", "coupon_code": "NULL", @@ -512,7 +512,7 @@ "sku": "'%sku%'", "name": "'%name%'", "description": "NULL", - "applied_rule_ids": "'3'", + "applied_rule_ids": "'%ruleId%", "additional_data": "NULL", "is_qty_decimal": "0", "no_discount": "0", From 498cd6d305e6224ed2eee6be19a086692396e9e0 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Tue, 23 Jan 2018 17:56:03 +0200 Subject: [PATCH 05/23] MAGETWO-84967: Set auto increment to 3 for Performance test plan --- .../src/Magento/Setup/Fixtures/_files/orders_fixture_data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/src/Magento/Setup/Fixtures/_files/orders_fixture_data.json b/setup/src/Magento/Setup/Fixtures/_files/orders_fixture_data.json index 29b1a56fe6d6e..fac103b3d9c53 100644 --- a/setup/src/Magento/Setup/Fixtures/_files/orders_fixture_data.json +++ b/setup/src/Magento/Setup/Fixtures/_files/orders_fixture_data.json @@ -102,7 +102,7 @@ "weight": 2.0000, "customer_dob": "NULL", "increment_id": "'%orderNumber%'", - "applied_rule_ids": "%rule_id%", + "applied_rule_ids": "%ruleId%", "base_currency_code": "'USD'", "customer_email": "'%email%'", "customer_firstname": "NULL", From 382736c0ca42cd8ace6a90a5d4c5fd75d0c5bc70 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Tue, 23 Jan 2018 18:31:38 +0200 Subject: [PATCH 06/23] MAGETWO-84967: Set auto increment to 3 for Performance test plan --- .../src/Magento/Setup/Fixtures/_files/orders_fixture_data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/src/Magento/Setup/Fixtures/_files/orders_fixture_data.json b/setup/src/Magento/Setup/Fixtures/_files/orders_fixture_data.json index fac103b3d9c53..d323246cf6d34 100644 --- a/setup/src/Magento/Setup/Fixtures/_files/orders_fixture_data.json +++ b/setup/src/Magento/Setup/Fixtures/_files/orders_fixture_data.json @@ -512,7 +512,7 @@ "sku": "'%sku%'", "name": "'%name%'", "description": "NULL", - "applied_rule_ids": "'%ruleId%", + "applied_rule_ids": "'%ruleId%'", "additional_data": "NULL", "is_qty_decimal": "0", "no_discount": "0", From 105b7ab77aaab28ffdd12d0049968595470d7a6d Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Thu, 25 Jan 2018 21:34:45 +0200 Subject: [PATCH 07/23] MAGETWO-84967: Set auto increment to 3 for Performance test plan --- .../Command/GenerateFixturesCommandTest.php | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php new file mode 100644 index 0000000000000..639fc908747eb --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php @@ -0,0 +1,48 @@ +objectManager = Bootstrap::getObjectManager(); + $this->command = $this->objectManager->create(GenerateFixturesCommand::class); + $this->commandTester = new CommandTester($this->command); + } + + public function testExecute() + { + $this->commandTester->execute( + [GenerateFixturesCommand::PROFILE_ARGUMENT => '/var/www/magento2ce/setup/performance-toolkit/profiles/ce/small.xml'] + ); + + $this->assertEquals(Cli::RETURN_SUCCESS, $this->commandTester->getStatusCode(), $this->commandTester->getDisplay()); + } +} From 64abd5debb1e7f401ab94f2dcfc4546df5fc0ab5 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Fri, 26 Jan 2018 22:16:04 +0200 Subject: [PATCH 08/23] MAGETWO-84967: Set auto increment to 3 for Performance test plan --- .../Command/GenerateFixturesCommandTest.php | 63 +++++++++++++++++-- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php index 639fc908747eb..ed1c6f66da58f 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php @@ -6,7 +6,7 @@ namespace Magento\Setup\Console\Command; use Magento\Framework\Console\Cli; -use Magento\Setup\Console\Command\GenerateFixturesCommand; +use Magento\Indexer\Console\Command\IndexerReindexCommand; use Magento\TestFramework\Helper\Bootstrap; use Symfony\Component\Console\Tester\CommandTester; @@ -16,6 +16,7 @@ */ class GenerateFixturesCommandTest extends \PHPUnit\Framework\TestCase { + private $fixtureModelMock; private $objectManager; /** * @var GenerateFixturesCommand @@ -33,16 +34,70 @@ class GenerateFixturesCommandTest extends \PHPUnit\Framework\TestCase public function setUp() { $this->objectManager = Bootstrap::getObjectManager(); - $this->command = $this->objectManager->create(GenerateFixturesCommand::class); + + $this->fixtureModelMock = $this->getMockBuilder(\Magento\Setup\Fixtures\FixtureModel::class) + ->setMethods(['getObjectManager']) + ->setConstructorArgs([$this->objectManager->get(IndexerReindexCommand::class)]) + ->getMock(); + $this->fixtureModelMock + ->method('getObjectManager') + ->willReturn($this->objectManager); + + $this->command = $this->objectManager->create( + GenerateFixturesCommand::class, + [ + 'fixtureModel' => $this->fixtureModelMock + ] + ); + + $this->setIncrement(3); + $this->commandTester = new CommandTester($this->command); + + parent::setUp(); + } + + public function tearDown() + { + $this->setIncrement(1); + + parent::tearDown(); } + /** + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + */ public function testExecute() { $this->commandTester->execute( - [GenerateFixturesCommand::PROFILE_ARGUMENT => '/var/www/magento2ce/setup/performance-toolkit/profiles/ce/small.xml'] + [GenerateFixturesCommand::PROFILE_ARGUMENT => BP . '/setup/performance-toolkit/profiles/ce/small.xml'] ); - $this->assertEquals(Cli::RETURN_SUCCESS, $this->commandTester->getStatusCode(), $this->commandTester->getDisplay()); + static::assertEquals(Cli::RETURN_SUCCESS, $this->commandTester->getStatusCode(), $this->commandTester->getDisplay()); + } + + /** + * @param $value + */ + private function setIncrement($value) + { + $db = Bootstrap::getInstance()->getBootstrap()->getApplication()->getDbInstance(); + /** @var \Magento\TestFramework\Db\Adapter\Mysql $connection */ + $connection = Bootstrap::getObjectManager()->create( + \Magento\TestFramework\Db\Adapter\Mysql::class, + [ + 'config' => [ + 'type' => 'pdo_mysql', + 'host' => $db->getHost(), + 'username' => $db->getUser(), + 'password' => $db->getPassword(), + 'dbname' => $db->getSchema(), + 'active' => true, + ] + ] + ); + $connection->query("SET GLOBAL auto_increment_increment=$value"); + $connection->query("SET GLOBAL auto_increment_offset=$value"); } } From 7a5b070ec4961f82f19028f518998f018dc3263f Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Mon, 29 Jan 2018 20:42:18 +0200 Subject: [PATCH 09/23] MAGETWO-84967: Set auto increment to 3 for Performance test plan --- .../Command/GenerateFixturesCommandTest.php | 62 +++++++++++++------ 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php index ed1c6f66da58f..51f3ebd19f411 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php @@ -5,7 +5,10 @@ */ namespace Magento\Setup\Console\Command; +use Magento\Framework\App\ObjectManagerFactory; +use Magento\Framework\App\ResourceConnection; use Magento\Framework\Console\Cli; +use Magento\Framework\ObjectManagerInterface; use Magento\Indexer\Console\Command\IndexerReindexCommand; use Magento\TestFramework\Helper\Bootstrap; use Symfony\Component\Console\Tester\CommandTester; @@ -16,7 +19,11 @@ */ class GenerateFixturesCommandTest extends \PHPUnit\Framework\TestCase { + private $indexerCommand; + private $fixtureModelMock; + + /** @var ObjectManagerInterface */ private $objectManager; /** * @var GenerateFixturesCommand @@ -50,10 +57,23 @@ public function setUp() ] ); - $this->setIncrement(3); + $objectFactoryMock = $this->getMockBuilder(ObjectManagerFactory::class) + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $objectFactoryMock + ->method('create') + ->willReturn($this->objectManager); + + $this->indexerCommand = new CommandTester($this->objectManager->create( + IndexerReindexCommand::class, + ['objectManagerFactory' => $objectFactoryMock] + )); $this->commandTester = new CommandTester($this->command); + $this->setIncrement(3); + parent::setUp(); } @@ -66,15 +86,27 @@ public function tearDown() /** * @magentoDbIsolation enabled - * @magentoAppIsolation enabled */ public function testExecute() { $this->commandTester->execute( - [GenerateFixturesCommand::PROFILE_ARGUMENT => BP . '/setup/performance-toolkit/profiles/ce/small.xml'] + [ + GenerateFixturesCommand::PROFILE_ARGUMENT => BP . '/setup/performance-toolkit/profiles/ce/small.xml', + '--' . GenerateFixturesCommand::SKIP_REINDEX_OPTION => true + ] + ); + $this->indexerCommand->execute([]); + + static::assertEquals( + Cli::RETURN_SUCCESS, + $this->indexerCommand->getStatusCode(), + $this->indexerCommand->getDisplay(true) ); - static::assertEquals(Cli::RETURN_SUCCESS, $this->commandTester->getStatusCode(), $this->commandTester->getDisplay()); + static::assertEquals(Cli::RETURN_SUCCESS, + $this->commandTester->getStatusCode(), + $this->commandTester->getDisplay(true) + ); } /** @@ -82,22 +114,12 @@ public function testExecute() */ private function setIncrement($value) { - $db = Bootstrap::getInstance()->getBootstrap()->getApplication()->getDbInstance(); - /** @var \Magento\TestFramework\Db\Adapter\Mysql $connection */ - $connection = Bootstrap::getObjectManager()->create( - \Magento\TestFramework\Db\Adapter\Mysql::class, - [ - 'config' => [ - 'type' => 'pdo_mysql', - 'host' => $db->getHost(), - 'username' => $db->getUser(), - 'password' => $db->getPassword(), - 'dbname' => $db->getSchema(), - 'active' => true, - ] - ] + /** @var ResourceConnection $connection */ + $connection = Bootstrap::getObjectManager()->get( + ResourceConnection::class ); - $connection->query("SET GLOBAL auto_increment_increment=$value"); - $connection->query("SET GLOBAL auto_increment_offset=$value"); + $db = $connection->getConnection(); + $db->query("SET @@session.auto_increment_increment=$value"); + $db->query("SET @@session.auto_increment_offset=$value"); } } From 600bef4789c044677d590c062563b34c49871030 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Mon, 29 Jan 2018 22:07:34 +0200 Subject: [PATCH 10/23] MAGETWO-84967: Set auto increment to 3 for Performance test plan --- .../Command/GenerateFixturesCommandTest.php | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php index 51f3ebd19f411..a77c8abf52f7c 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php @@ -10,6 +10,7 @@ use Magento\Framework\Console\Cli; use Magento\Framework\ObjectManagerInterface; use Magento\Indexer\Console\Command\IndexerReindexCommand; +use Magento\Setup\Fixtures\FixtureModel; use Magento\TestFramework\Helper\Bootstrap; use Symfony\Component\Console\Tester\CommandTester; @@ -19,20 +20,19 @@ */ class GenerateFixturesCommandTest extends \PHPUnit\Framework\TestCase { + /** @var CommandTester */ private $indexerCommand; + /** @var FixtureModel */ private $fixtureModelMock; /** @var ObjectManagerInterface */ private $objectManager; - /** - * @var GenerateFixturesCommand - */ + + /** @var GenerateFixturesCommand */ private $command; - /** - * @var CommandTester - */ + /** @var CommandTester */ private $commandTester; /** @@ -42,7 +42,7 @@ public function setUp() { $this->objectManager = Bootstrap::getObjectManager(); - $this->fixtureModelMock = $this->getMockBuilder(\Magento\Setup\Fixtures\FixtureModel::class) + $this->fixtureModelMock = $this->getMockBuilder(FixtureModel::class) ->setMethods(['getObjectManager']) ->setConstructorArgs([$this->objectManager->get(IndexerReindexCommand::class)]) ->getMock(); @@ -77,6 +77,9 @@ public function setUp() parent::setUp(); } + /** + * teardown + */ public function tearDown() { $this->setIncrement(1); @@ -103,7 +106,8 @@ public function testExecute() $this->indexerCommand->getDisplay(true) ); - static::assertEquals(Cli::RETURN_SUCCESS, + static::assertEquals( + Cli::RETURN_SUCCESS, $this->commandTester->getStatusCode(), $this->commandTester->getDisplay(true) ); @@ -114,11 +118,8 @@ public function testExecute() */ private function setIncrement($value) { - /** @var ResourceConnection $connection */ - $connection = Bootstrap::getObjectManager()->get( - ResourceConnection::class - ); - $db = $connection->getConnection(); + /** @var \Magento\Framework\DB\Adapter\AdapterInterface $db */ + $db = Bootstrap::getObjectManager()->get(ResourceConnection::class)->getConnection(); $db->query("SET @@session.auto_increment_increment=$value"); $db->query("SET @@session.auto_increment_offset=$value"); } From 344638c439fd08261a863840ca95500236027b2e Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Tue, 30 Jan 2018 12:47:09 +0200 Subject: [PATCH 11/23] MAGETWO-84967: Set auto increment to 3 for Performance test plan --- .../Setup/Console/Command/GenerateFixturesCommandTest.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php index a77c8abf52f7c..adbb2bdf1866f 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php @@ -87,9 +87,6 @@ public function tearDown() parent::tearDown(); } - /** - * @magentoDbIsolation enabled - */ public function testExecute() { $this->commandTester->execute( From c85d0b0594d2242c56913363307f8d063cf45a6c Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Tue, 30 Jan 2018 15:35:29 +0200 Subject: [PATCH 12/23] MAGETWO-84967: Set auto increment to 3 for Performance test plan --- .../Command/GenerateFixturesCommandTest.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php index adbb2bdf1866f..16da1aaf9105e 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php @@ -77,6 +77,17 @@ public function setUp() parent::setUp(); } + private function getEdition() + { + if (file_exists(BP . '/setup/performance-toolkit/profiles/b2b/small.xml')) { + return 'b2b'; + } elseif (file_exists(BP . '/setup/performance-toolkit/profiles/ee/small.xml')) { + return 'ee'; + } else { + return 'ce'; + } + } + /** * teardown */ @@ -89,9 +100,10 @@ public function tearDown() public function testExecute() { + $profile = BP . "/setup/performance-toolkit/profiles/{$this->getEdition()}/small.xml"; $this->commandTester->execute( [ - GenerateFixturesCommand::PROFILE_ARGUMENT => BP . '/setup/performance-toolkit/profiles/ce/small.xml', + GenerateFixturesCommand::PROFILE_ARGUMENT => $profile, '--' . GenerateFixturesCommand::SKIP_REINDEX_OPTION => true ] ); From fcbfe1fd491986c815b7b51ddef7a68e78584d5b Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Tue, 30 Jan 2018 16:08:08 +0200 Subject: [PATCH 13/23] MAGETWO-84967: Set auto increment to 3 for Performance test plan --- .../Setup/Console/Command/GenerateFixturesCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php index 16da1aaf9105e..9060dc64f7366 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php @@ -18,7 +18,7 @@ * Class GenerateFixturesCommandCommandTest * @package Magento\Setup\Console\Command */ -class GenerateFixturesCommandTest extends \PHPUnit\Framework\TestCase +class GenerateFixturesCommandTest extends \Magento\TestFramework\Indexer\TestCase { /** @var CommandTester */ private $indexerCommand; From 7a600886c7073c74b3f652ff107197a3e7a532cf Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Tue, 30 Jan 2018 16:27:52 +0200 Subject: [PATCH 14/23] MAGETWO-84967: Set auto increment to 3 for Performance test plan --- .../Command/GenerateFixturesCommandTest.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php index 9060dc64f7366..349a4d2183a9b 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php @@ -77,6 +77,9 @@ public function setUp() parent::setUp(); } + /** + * @return string + */ private function getEdition() { if (file_exists(BP . '/setup/performance-toolkit/profiles/b2b/small.xml')) { @@ -98,6 +101,36 @@ public function tearDown() parent::tearDown(); } + public static function tearDownAfterClass() + { + parent::tearDownAfterClass(); + + /** @var $appCache \Magento\Framework\App\Cache */ + $appCache = Bootstrap::getObjectManager()->get(\Magento\Framework\App\Cache::class); + $appCache->clean( + [ + \Magento\Eav\Model\Cache\Type::CACHE_TAG, + \Magento\Eav\Model\Entity\Attribute::CACHE_TAG, + ] + ); + } + + public static function setUpBeforeClass() + { + $db = Bootstrap::getInstance()->getBootstrap() + ->getApplication() + ->getDbInstance(); + if (!$db->isDbDumpExists()) { + throw new \LogicException('DB dump does not exist.'); + } + $db->restoreFromDbDump(); + + parent::setUpBeforeClass(); + } + + /** + * + */ public function testExecute() { $profile = BP . "/setup/performance-toolkit/profiles/{$this->getEdition()}/small.xml"; From 60fb61da6d7528df39f63848a1b56426a2fa99a8 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Fri, 2 Feb 2018 13:15:31 +0200 Subject: [PATCH 15/23] MAGETWO-84967: Set auto increment to 3 for Performance test plan --- .../Command/GenerateFixturesCommandTest.php | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php index 349a4d2183a9b..b53b1aaa5637e 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php @@ -101,20 +101,6 @@ public function tearDown() parent::tearDown(); } - public static function tearDownAfterClass() - { - parent::tearDownAfterClass(); - - /** @var $appCache \Magento\Framework\App\Cache */ - $appCache = Bootstrap::getObjectManager()->get(\Magento\Framework\App\Cache::class); - $appCache->clean( - [ - \Magento\Eav\Model\Cache\Type::CACHE_TAG, - \Magento\Eav\Model\Entity\Attribute::CACHE_TAG, - ] - ); - } - public static function setUpBeforeClass() { $db = Bootstrap::getInstance()->getBootstrap() @@ -129,7 +115,8 @@ public static function setUpBeforeClass() } /** - * + * @magentoAppArea adminhtml + * @magentoAppIsolation enabled */ public function testExecute() { From 2851b7123e4343078ee6f2002d0c31597ff6f331 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Fri, 2 Feb 2018 16:56:51 +0200 Subject: [PATCH 16/23] MAGETWO-84967: Set auto increment to 3 for Performance test plan --- .../Setup/Console/Command/GenerateFixturesCommandTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php index b53b1aaa5637e..511406187c84d 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php @@ -42,6 +42,8 @@ public function setUp() { $this->objectManager = Bootstrap::getObjectManager(); + $this->objectManager->get(\Magento\TestFramework\App\Config::class)->clean(); + $this->fixtureModelMock = $this->getMockBuilder(FixtureModel::class) ->setMethods(['getObjectManager']) ->setConstructorArgs([$this->objectManager->get(IndexerReindexCommand::class)]) From b3b217f963b52371ff692c092cf676831917dd0b Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Mon, 5 Feb 2018 14:57:03 +0200 Subject: [PATCH 17/23] MAGETWO-73696: Sorting by price column in admin doesn't count disabled products --- .../Catalog/Ui/DataProvider/Product/ProductCollection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductCollection.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductCollection.php index ca6855af9e7f1..ac6c15dbc1d41 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductCollection.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductCollection.php @@ -1,6 +1,6 @@ Date: Mon, 5 Feb 2018 15:45:05 +0200 Subject: [PATCH 18/23] MAGETWO-87445: FATAL error on compiler generation on PAT 2.2 Trend --- .../Plugin/Model/ResourceModel/ReadSnapshotPlugin.php | 8 ++++---- .../Eav/Model/Entity/Attribute/AbstractAttribute.php | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Catalog/Plugin/Model/ResourceModel/ReadSnapshotPlugin.php b/app/code/Magento/Catalog/Plugin/Model/ResourceModel/ReadSnapshotPlugin.php index 1fbba1279928e..4dae4ec68efa8 100644 --- a/app/code/Magento/Catalog/Plugin/Model/ResourceModel/ReadSnapshotPlugin.php +++ b/app/code/Magento/Catalog/Plugin/Model/ResourceModel/ReadSnapshotPlugin.php @@ -7,7 +7,7 @@ use Magento\Catalog\Api\Data\CategoryInterface; use Magento\Catalog\Api\Data\ProductInterface; -use Magento\Eav\Model\Config; +use Magento\Eav\Model\Config as EavConfig; use Magento\Eav\Model\ResourceModel\ReadSnapshot; use Magento\Framework\EntityManager\MetadataPool; @@ -24,17 +24,17 @@ class ReadSnapshotPlugin private $metadataPool; /** - * @var Config + * @var EavConfig */ private $config; /** * @param MetadataPool $metadataPool - * @param Config $config + * @param EavConfig $config */ public function __construct( MetadataPool $metadataPool, - Config $config + EavConfig $config ) { $this->metadataPool = $metadataPool; $this->config = $config; diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php index bfd197758dc8b..19877a51c4869 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php @@ -133,6 +133,8 @@ abstract class AbstractAttribute extends \Magento\Framework\Model\AbstractExtens * @var array */ private $emptyStringTypes = [ + 'int', + 'decimal', 'datetime', 'varchar', 'text', From 8051454fd069cc6c5908b2e204d3d9956c9f00ec Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Mon, 5 Feb 2018 16:43:19 +0200 Subject: [PATCH 19/23] MAGETWO-73696: Sorting by price column in admin doesn't count disabled products --- .../Catalog/Ui/DataProvider/Product/ProductCollection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductCollection.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductCollection.php index ac6c15dbc1d41..f4334bc25efd8 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductCollection.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductCollection.php @@ -1,6 +1,6 @@ Date: Mon, 5 Feb 2018 16:50:25 +0200 Subject: [PATCH 20/23] MAGETWO-72597: [2.2.x] - Impossible to perform mass update on product with 60+ attributes in system --- .../Model/ResourceModel/Entity/Attribute/CollectionTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/CollectionTest.php b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/CollectionTest.php index c1a94a7ca4a50..ae0053bc1a78f 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/CollectionTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/CollectionTest.php @@ -1,7 +1,6 @@ Date: Tue, 6 Feb 2018 10:57:03 +0200 Subject: [PATCH 21/23] MAGETWO-84967: Set auto increment to 3 for Performance test plan --- .../Setup/Console/Command/GenerateFixturesCommandTest.php | 8 +------- .../Magento/Setup/Console/Command/_files/edition | 1 + 2 files changed, 2 insertions(+), 7 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/edition diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php index 511406187c84d..eaa8b2f6fdbbf 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/GenerateFixturesCommandTest.php @@ -84,13 +84,7 @@ public function setUp() */ private function getEdition() { - if (file_exists(BP . '/setup/performance-toolkit/profiles/b2b/small.xml')) { - return 'b2b'; - } elseif (file_exists(BP . '/setup/performance-toolkit/profiles/ee/small.xml')) { - return 'ee'; - } else { - return 'ce'; - } + return trim(file_get_contents(__DIR__ . '/_files/edition')); } /** diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/edition b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/edition new file mode 100644 index 0000000000000..a2a77c324b740 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/edition @@ -0,0 +1 @@ +ce From 33df10085ef5e18d11bb6a0b28007f236c038eb5 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Tue, 6 Feb 2018 12:53:13 +0200 Subject: [PATCH 22/23] MAGETWO-72597: [2.2.x] - Impossible to perform mass update on product with 60+ attributes in system --- .../Model/ResourceModel/Entity/Attribute/CollectionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/CollectionTest.php b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/CollectionTest.php index ae0053bc1a78f..138e1363bb6dd 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/CollectionTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/CollectionTest.php @@ -14,7 +14,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CollectionTest extends \PHPUnit_Framework_TestCase +class CollectionTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection From 579785692430b2ff7e311cebbdace8d193cac164 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Tue, 6 Feb 2018 12:56:23 +0200 Subject: [PATCH 23/23] MAGETWO-87445: FATAL error on compiler generation on PAT 2.2 Trend --- .../Unit/Model/Entity/Attribute/AbstractAttributeTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/AbstractAttributeTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/AbstractAttributeTest.php index 68fcb7e979e38..5f5398c77488c 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/AbstractAttributeTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/AbstractAttributeTest.php @@ -228,8 +228,8 @@ public function testIsValueEmpty($isEmpty, $value, $attributeType) public function attributeValueDataProvider() { return [ - [false, '', 'int'], - [false, '', 'decimal'], + [true, '', 'int'], + [true, '', 'decimal'], [true, '', 'datetime'], [true, '', 'varchar'], [true, '', 'text'],