From 291651965a96eecbab84cb6aff9275133e53fdc7 Mon Sep 17 00:00:00 2001 From: Leonid Poluianov Date: Fri, 12 Jun 2020 14:18:50 -0500 Subject: [PATCH] [17] Merge api-proto with develop #71 --- .../Magento/Webapi/JoinDirectivesTest.php | 3 +++ .../Magento/TestFramework/Application.php | 24 ++++++++++++++++++- .../Adminhtml/Product/Set/SaveTest.php | 1 + .../testsuite/Magento/Sales/_files/quote.php | 12 ++++++---- .../TestFramework/SetupApplication.php | 13 +++++++++- .../TestFramework/Dependency/DbRule.php | 5 +++- 6 files changed, 51 insertions(+), 7 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/JoinDirectivesTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/JoinDirectivesTest.php index 4d89e3a0b582a..5e278e6058dc9 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/JoinDirectivesTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/JoinDirectivesTest.php @@ -50,6 +50,7 @@ protected function setUp(): void * * @magentoApiDataFixture Magento/SalesRule/_files/rules_rollback.php * @magentoApiDataFixture Magento/Sales/_files/quote.php + * @magentoAppIsolation enabled */ public function testGetList() { @@ -87,6 +88,7 @@ public function testGetList() /** * @magentoApiDataFixture Magento/Sales/_files/invoice.php + * @magentoAppIsolation enabled */ public function testAutoGeneratedGetList() { @@ -131,6 +133,7 @@ public function testAutoGeneratedGetList() * Test get list of orders with extension attributes. * * @magentoApiDataFixture Magento/Sales/_files/order.php + * @magentoAppIsolation enabled */ public function testGetOrdertList() { diff --git a/dev/tests/integration/framework/Magento/TestFramework/Application.php b/dev/tests/integration/framework/Magento/TestFramework/Application.php index f0ce2e24545eb..8d0514215622a 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Application.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Application.php @@ -168,10 +168,12 @@ public function __construct( $loadTestExtensionAttributes = false ) { if (getcwd() != BP . '/dev/tests/integration') { + // phpcs:ignore Magento2.Functions.DiscouragedFunction chdir(BP . '/dev/tests/integration'); } $this->_shell = $shell; $this->installConfigFile = $installConfigFile; + // phpcs:ignore Magento2.Functions.DiscouragedFunction $this->_globalConfigDir = realpath($globalConfigDir); $this->_appMode = $appMode; $this->installDir = $installDir; @@ -251,6 +253,7 @@ public function getDbInstance() protected function getInstallConfig() { if (null === $this->installConfig) { + // phpcs:ignore Magento2.Security.IncludeFile $this->installConfig = include $this->installConfigFile; } return $this->installConfig; @@ -293,6 +296,7 @@ public function getInitParams() */ public function isInstalled() { + // phpcs:ignore Magento2.Functions.DiscouragedFunction return is_file($this->getLocalConfig()); } @@ -419,11 +423,23 @@ public function initialize($overriddenParams = []) $sequence = $objectManager->get(\Magento\TestFramework\Db\Sequence::class); $sequence->generateSequences(); } - + $this->createDynamicTables(); $objectManager->create(\Magento\TestFramework\Config::class, ['configPath' => $this->globalConfigFile]) ->rewriteAdditionalConfig(); } + /** + * Create dynamic tables + * + * @return void + */ + protected function createDynamicTables() + { + /** @var \Magento\TestFramework\Db\DynamicTables $dynamicTables */ + $dynamicTables = Helper\Bootstrap::getObjectManager()->get(\Magento\TestFramework\Db\DynamicTables::class); + $dynamicTables->createTables(); + } + /** * Reset and initialize again an already installed application * @@ -552,8 +568,10 @@ private function copyAppConfigFiles() ); foreach ($globalConfigFiles as $file) { $targetFile = $this->_configDir . str_replace($this->_globalConfigDir, '', $file); + // phpcs:ignore Magento2.Functions.DiscouragedFunction $this->_ensureDirExists(dirname($targetFile)); if ($file !== $targetFile) { + // phpcs:ignore Magento2.Functions.DiscouragedFunction copy($file, $targetFile); } } @@ -567,6 +585,7 @@ private function copyAppConfigFiles() private function copyGlobalConfigFile() { $targetFile = $this->_configDir . '/config.local.php'; + // phpcs:ignore Magento2.Functions.DiscouragedFunction copy($this->globalConfigFile, $targetFile); } @@ -636,10 +655,13 @@ protected function _resetApp() */ protected function _ensureDirExists($dir) { + // phpcs:ignore Magento2.Functions.DiscouragedFunction if (!file_exists($dir)) { $old = umask(0); + // phpcs:ignore Magento2.Functions.DiscouragedFunction mkdir($dir, 0777, true); umask($old); + // phpcs:ignore Magento2.Functions.DiscouragedFunction } elseif (!is_dir($dir)) { throw new \Magento\Framework\Exception\LocalizedException(__("'%1' is not a directory.", $dir)); } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php index cdbc9bc90362f..c31266f06225e 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php @@ -224,6 +224,7 @@ public function testAlreadyExistsExceptionProcessingWhenGroupCodeIsDuplicated(): */ public function testRemoveAttributeFromAttributeSet(): void { + $this->markTestSkipped('ECP-739'); $message = 'Attempt to load value of nonexistent EAV attribute'; $this->removeSyslog(); $attributeSet = $this->getAttributeSetByName('new_attribute_set'); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php index 5be2fcefbde26..ea39a8bf78b4e 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php @@ -3,7 +3,11 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('frontend'); + +$storeManager = Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get(\Magento\Store\Model\StoreManagerInterface::class); $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class); $product->setTypeId('simple') ->setId(1) @@ -23,7 +27,9 @@ 'is_in_stock' => 1, 'manage_stock' => 1, ] - )->save(); + ) + ->setWebsiteIds([$storeManager->getStore()->getWebsiteId()]) + ->save(); $productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); @@ -39,9 +45,7 @@ $shippingAddress = clone $billingAddress; $shippingAddress->setId(null)->setAddressType('shipping'); -$store = Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get(\Magento\Store\Model\StoreManagerInterface::class) - ->getStore(); +$store = $storeManager->getStore(); /** @var \Magento\Quote\Model\Quote $quote */ $quote = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Quote\Model\Quote::class); diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/SetupApplication.php b/dev/tests/setup-integration/framework/Magento/TestFramework/SetupApplication.php index 719979c83db39..69005ec82433b 100644 --- a/dev/tests/setup-integration/framework/Magento/TestFramework/SetupApplication.php +++ b/dev/tests/setup-integration/framework/Magento/TestFramework/SetupApplication.php @@ -28,10 +28,21 @@ class SetupApplication extends Application protected $canInstallSequence = false; /** - * {@inheritdoc} + * @inheritdoc */ public function run() { + // phpcs:ignore Magento2.Exceptions.DirectThrow throw new \Exception("Can't start application."); } + + /** + * Create dynamic tables + * + * @return null + */ + protected function createDynamicTables() + { + return null; + } } diff --git a/dev/tests/static/framework/Magento/TestFramework/Dependency/DbRule.php b/dev/tests/static/framework/Magento/TestFramework/Dependency/DbRule.php index cb3a9e2cc9c35..b0d3d861a4cf7 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Dependency/DbRule.php +++ b/dev/tests/static/framework/Magento/TestFramework/Dependency/DbRule.php @@ -7,6 +7,9 @@ */ namespace Magento\TestFramework\Dependency; +/** + * Class to get DB dependencies information + */ class DbRule implements \Magento\TestFramework\Dependency\RuleInterface { /** @@ -37,7 +40,7 @@ public function __construct(array $tables) */ public function getDependencyInfo($currentModule, $fileType, $file, &$contents) { - if ('php' != $fileType || !preg_match('#.*/(Setup|Resource)/.*\.php$#', $file)) { + if ('php' != $fileType || !preg_match('#.*/(Setup|Resource|Query)/.*\.php$#', $file)) { return []; }