From 6e6a5c730a82b8a24d6d7a54e37afe5f97a50e08 Mon Sep 17 00:00:00 2001 From: Ivan Gavryshko <igavryshko@ebay.com> Date: Tue, 12 May 2015 11:18:37 -0500 Subject: [PATCH] MAGETWO-36070: Move dev/tools/performance-toolkit/generate.php - fixed static tests --- .../Model/FixtureModelTest.php} | 41 +++++++++---------- .../Model}/_files/small.xml | 0 .../Model}/_files/tax_rates.csv | 0 .../Setup/Fixtures/CartPriceRulesFixture.php | 1 + .../Fixtures/CatalogPriceRulesFixture.php | 2 +- .../Setup/Fixtures/CategoriesFixture.php | 2 - .../Setup/Fixtures/ConfigsApplyFixture.php | 3 +- .../Fixtures/ConfigurableProductsFixture.php | 7 +++- .../Setup/Fixtures/CustomersFixture.php | 2 - .../Setup/Fixtures/EavVariationsFixture.php | 2 - .../Magento/Setup/Fixtures/OrdersFixture.php | 4 ++ .../Magento/Setup/Fixtures/StoresFixture.php | 1 + 12 files changed, 34 insertions(+), 31 deletions(-) rename dev/tests/integration/testsuite/Magento/{ToolkitFramework/ApplicationTest.php => Setup/Model/FixtureModelTest.php} (60%) rename dev/tests/integration/testsuite/Magento/{ToolkitFramework => Setup/Model}/_files/small.xml (100%) rename dev/tests/integration/testsuite/Magento/{ToolkitFramework => Setup/Model}/_files/tax_rates.csv (100%) diff --git a/dev/tests/integration/testsuite/Magento/ToolkitFramework/ApplicationTest.php b/dev/tests/integration/testsuite/Magento/Setup/Model/FixtureModelTest.php similarity index 60% rename from dev/tests/integration/testsuite/Magento/ToolkitFramework/ApplicationTest.php rename to dev/tests/integration/testsuite/Magento/Setup/Model/FixtureModelTest.php index 64c7f8867cb..38c98f15381 100644 --- a/dev/tests/integration/testsuite/Magento/ToolkitFramework/ApplicationTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Model/FixtureModelTest.php @@ -3,12 +3,15 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\ToolkitFramework; + +namespace Magento\Setup\Fixtures; + +use Magento\TestFramework\Helper\Bootstrap; /** * Class Application test */ -class ApplicationTest extends \Magento\TestFramework\Indexer\TestCase +class FixtureModelTest extends \Magento\TestFramework\Indexer\TestCase { /** * Profile generator working directory @@ -24,31 +27,27 @@ class ApplicationTest extends \Magento\TestFramework\Indexer\TestCase public static function setUpBeforeClass() { - self::$_generatorWorkingDir = realpath(__DIR__ . '/../../../../../tools/performance-toolkit'); + self::$_generatorWorkingDir = realpath(__DIR__ . '/../../../../../../setup/performance-toolkit'); copy( self::$_generatorWorkingDir . '/fixtures/tax_rates.csv', self::$_generatorWorkingDir . '/fixtures/tax_rates.csv.bak' ); - copy(__DIR__ . '/_files/tax_rates.csv', self::$_generatorWorkingDir . '/fixtures/tax_rates.csv'); + copy( + __DIR__ . '/_files/tax_rates.csv', + self::$_generatorWorkingDir . '/../src/Magento/Setup/Fixtures/tax_rates.csv' + ); parent::setUpBeforeClass(); } public function testTest() { - $config = \Magento\ToolkitFramework\Config::getInstance(); - $config->loadConfig(__DIR__ . '/_files/small.xml'); - /** @var \Magento\TestFramework\Application $itfApplication */ - $itfApplication = \Magento\TestFramework\Helper\Bootstrap::getInstance()->getBootstrap()->getApplication(); - $shell = $this->getMock('Magento\Framework\Shell', [], [], '', false); - - $application = new \Magento\ToolkitFramework\Application( - $itfApplication->getTempDir(), - $shell, - $itfApplication->getInitParams() - ); + $reindexCommand = Bootstrap::getObjectManager()->get('Magento\Indexer\Console\Command\IndexerReindexCommand'); + $parser = Bootstrap::getObjectManager()->get('Magento\Framework\Xml\Parser'); + $model = new FixtureModel($reindexCommand, $parser, []); + $model->loadConfig(__DIR__ . '/_files/small.xml'); + $model->initObjectManager(); - $application->bootstrap(); - foreach ($application->loadFixtures()->getFixtures() as $fixture) { + foreach ($model->loadFixtures()->getFixtures() as $fixture) { $fixture->execute(); } } @@ -56,13 +55,13 @@ class ApplicationTest extends \Magento\TestFramework\Indexer\TestCase public static function tearDownAfterClass() { parent::tearDownAfterClass(); - unlink(self::$_generatorWorkingDir . '/fixtures/tax_rates.csv'); + unlink(self::$_generatorWorkingDir . '/../src/Magento/Setup/Fixtures/tax_rates.csv'); rename( - self::$_generatorWorkingDir . '/fixtures/tax_rates.csv.bak', - self::$_generatorWorkingDir . '/fixtures/tax_rates.csv' + self::$_generatorWorkingDir . '/../src/Magento/Setup/Fixtures/tax_rates.csv.bak', + self::$_generatorWorkingDir . '/../src/Magento/Setup/Fixtures/tax_rates.csv' ); /** @var $appCache \Magento\Framework\App\Cache */ - $appCache = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\App\Cache'); + $appCache = Bootstrap::getObjectManager()->get('Magento\Framework\App\Cache'); $appCache->clean( [ \Magento\Eav\Model\Cache\Type::CACHE_TAG, diff --git a/dev/tests/integration/testsuite/Magento/ToolkitFramework/_files/small.xml b/dev/tests/integration/testsuite/Magento/Setup/Model/_files/small.xml similarity index 100% rename from dev/tests/integration/testsuite/Magento/ToolkitFramework/_files/small.xml rename to dev/tests/integration/testsuite/Magento/Setup/Model/_files/small.xml diff --git a/dev/tests/integration/testsuite/Magento/ToolkitFramework/_files/tax_rates.csv b/dev/tests/integration/testsuite/Magento/Setup/Model/_files/tax_rates.csv similarity index 100% rename from dev/tests/integration/testsuite/Magento/ToolkitFramework/_files/tax_rates.csv rename to dev/tests/integration/testsuite/Magento/Setup/Model/_files/tax_rates.csv diff --git a/setup/src/Magento/Setup/Fixtures/CartPriceRulesFixture.php b/setup/src/Magento/Setup/Fixtures/CartPriceRulesFixture.php index 08373f57ea5..3cb6ab044b0 100644 --- a/setup/src/Magento/Setup/Fixtures/CartPriceRulesFixture.php +++ b/setup/src/Magento/Setup/Fixtures/CartPriceRulesFixture.php @@ -18,6 +18,7 @@ class CartPriceRulesFixture extends Fixture /** * {@inheritdoc} + * @SuppressWarnings(PHPMD) */ public function execute() { diff --git a/setup/src/Magento/Setup/Fixtures/CatalogPriceRulesFixture.php b/setup/src/Magento/Setup/Fixtures/CatalogPriceRulesFixture.php index 92149c83ba3..3fd0e674ec2 100644 --- a/setup/src/Magento/Setup/Fixtures/CatalogPriceRulesFixture.php +++ b/setup/src/Magento/Setup/Fixtures/CatalogPriceRulesFixture.php @@ -18,7 +18,7 @@ class CatalogPriceRulesFixture extends Fixture /** * {@inheritdoc} - * + * @SuppressWarnings(PHPMD) */ public function execute() { diff --git a/setup/src/Magento/Setup/Fixtures/CategoriesFixture.php b/setup/src/Magento/Setup/Fixtures/CategoriesFixture.php index 7a512d02675..0845cb5e350 100644 --- a/setup/src/Magento/Setup/Fixtures/CategoriesFixture.php +++ b/setup/src/Magento/Setup/Fixtures/CategoriesFixture.php @@ -44,7 +44,6 @@ class CategoriesFixture extends Fixture $i++; } $groupNumber = 0; - $anchorStep = 2; $categoryIndex = 1; while ($categoryIndex <= $categoriesNumber) { @@ -58,7 +57,6 @@ class CategoriesFixture extends Fixture ->setAvailableSortBy('name') ->setDefaultSortBy('name') ->setIsActive(true) - //->setIsAnchor($categoryIndex++ % $anchorStep == 0) ->save(); $categoryIndex++; $categoryPath[$groupNumber] .= '/' . $category->getName(); diff --git a/setup/src/Magento/Setup/Fixtures/ConfigsApplyFixture.php b/setup/src/Magento/Setup/Fixtures/ConfigsApplyFixture.php index 5793598210a..1dfd544552a 100644 --- a/setup/src/Magento/Setup/Fixtures/ConfigsApplyFixture.php +++ b/setup/src/Magento/Setup/Fixtures/ConfigsApplyFixture.php @@ -21,11 +21,10 @@ class ConfigsApplyFixture extends Fixture */ public function execute() { - $configs = $this->fixtureModel->getValue('configs', array()); + $configs = $this->fixtureModel->getValue('configs', []); if (empty($configs)) { return; } - $configs = $this->fixtureModel->getValue('configs', []); $this->fixtureModel->resetObjectManager(); foreach ($configs['config'] as $config) { diff --git a/setup/src/Magento/Setup/Fixtures/ConfigurableProductsFixture.php b/setup/src/Magento/Setup/Fixtures/ConfigurableProductsFixture.php index 2d0f51e7cdc..7d8297a1a64 100644 --- a/setup/src/Magento/Setup/Fixtures/ConfigurableProductsFixture.php +++ b/setup/src/Magento/Setup/Fixtures/ConfigurableProductsFixture.php @@ -19,9 +19,10 @@ class ConfigurableProductsFixture extends Fixture */ protected $priority = 50; + //@codingStandardsIgnoreStart /** * Get CSV template headers - * + * @SuppressWarnings(PHPMD) * @return array */ protected function getHeaders() @@ -145,6 +146,9 @@ class ConfigurableProductsFixture extends Fixture * @param Closure|mixed $productCategory * @param Closure|mixed $productRootCategory * @param Closure|mixed $productWebsite + * + * @SuppressWarnings(PHPMD) + * * @return array */ protected function getRows($productCategory, $productRootCategory, $productWebsite) @@ -903,6 +907,7 @@ class ConfigurableProductsFixture extends Fixture $import->importSource(); } + // @codingStandardsIgnoreEnd /** * {@inheritdoc} diff --git a/setup/src/Magento/Setup/Fixtures/CustomersFixture.php b/setup/src/Magento/Setup/Fixtures/CustomersFixture.php index e96460fffa2..c2390cd9891 100644 --- a/setup/src/Magento/Setup/Fixtures/CustomersFixture.php +++ b/setup/src/Magento/Setup/Fixtures/CustomersFixture.php @@ -31,8 +31,6 @@ class CustomersFixture extends Fixture /** @var \Magento\Store\Model\StoreManager $storeManager */ $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); - /** @var $category \Magento\Catalog\Model\Category */ - $category = $this->fixtureModel->getObjectManager()->get('Magento\Catalog\Model\Category'); /** @var $defaultStoreView \Magento\Store\Model\Store */ $defaultStoreView = $storeManager->getDefaultStoreView(); $defaultStoreViewId = $defaultStoreView->getStoreId(); diff --git a/setup/src/Magento/Setup/Fixtures/EavVariationsFixture.php b/setup/src/Magento/Setup/Fixtures/EavVariationsFixture.php index e6baa1aabfb..c5ea2edf5f2 100644 --- a/setup/src/Magento/Setup/Fixtures/EavVariationsFixture.php +++ b/setup/src/Magento/Setup/Fixtures/EavVariationsFixture.php @@ -31,8 +31,6 @@ class EavVariationsFixture extends Fixture /* @var $model \Magento\Catalog\Model\Resource\Eav\Attribute */ $model = $this->fixtureModel->getObjectManager()->create('Magento\Catalog\Model\Resource\Eav\Attribute'); - /* @var $helper \Magento\Catalog\Helper\Product */ - $helper = $this->fixtureModel->getObjectManager()->get('Magento\Catalog\Helper\Product'); /** @var \Magento\Store\Model\StoreManager $storeManager */ $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); $stores = $storeManager->getStores(); diff --git a/setup/src/Magento/Setup/Fixtures/OrdersFixture.php b/setup/src/Magento/Setup/Fixtures/OrdersFixture.php index d82e1584bd8..d947a9ee919 100644 --- a/setup/src/Magento/Setup/Fixtures/OrdersFixture.php +++ b/setup/src/Magento/Setup/Fixtures/OrdersFixture.php @@ -18,6 +18,7 @@ class OrdersFixture extends Fixture /** * {@inheritdoc} + * @SuppressWarnings(PHPMD) */ public function execute() { @@ -197,6 +198,8 @@ class OrdersFixture extends Fixture $simpleProductIdLen[0] = strlen($simpleProductId[0]($entityId)); $simpleProductIdLen[1] = strlen($simpleProductId[1]($entityId)); + //@codingStandardsIgnoreStart + $queries .= "INSERT INTO `{$eavEntityStoreTableName}` (`entity_store_id`, `entity_type_id`, `store_id`, `increment_prefix`, `increment_last_id`) VALUES ({$productStoreId($entityId)}, 5, {$productStoreId($entityId)}, '{$productStoreId($entityId)}', '{$orderNumber}') ON DUPLICATE KEY UPDATE `increment_last_id`='{$orderNumber}';"; $quoteId = $entityId; @@ -262,6 +265,7 @@ class OrdersFixture extends Fixture $salesOrderStatusHistoryId = $salesOrderId; $queries .= "INSERT INTO `{$salesOrderStatusHistoryTableName}` (`entity_id`, `parent_id`, `is_customer_notified`, `is_visible_on_front`, `comment`, `status`, `created_at`, `entity_name`) VALUES ({$salesOrderStatusHistoryId}, {$salesOrderId}, 1, 0, NULL, 'pending', '{$time}', 'order');"; + // @codingStandardsIgnoreEnd $writeAdapter->multiQuery($queries); $entityId++; diff --git a/setup/src/Magento/Setup/Fixtures/StoresFixture.php b/setup/src/Magento/Setup/Fixtures/StoresFixture.php index da9186baeae..8e4c7f7517a 100644 --- a/setup/src/Magento/Setup/Fixtures/StoresFixture.php +++ b/setup/src/Magento/Setup/Fixtures/StoresFixture.php @@ -18,6 +18,7 @@ class StoresFixture extends Fixture /** * {@inheritdoc} + * @SuppressWarnings(PHPMD) */ public function execute() { -- GitLab