Skip to content

Commit a3d3fe2

Browse files
committed
[17] Merge api-proto with develop #71
1 parent d946618 commit a3d3fe2

File tree

12 files changed

+180
-13
lines changed

12 files changed

+180
-13
lines changed

dev/tests/api-functional/testsuite/Magento/Webapi/JoinDirectivesTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ protected function setUp(): void
5050
*
5151
* @magentoApiDataFixture Magento/SalesRule/_files/rules_rollback.php
5252
* @magentoApiDataFixture Magento/Sales/_files/quote.php
53+
* @magentoAppIsolation enabled
5354
*/
5455
public function testGetList()
5556
{
@@ -87,6 +88,7 @@ public function testGetList()
8788

8889
/**
8990
* @magentoApiDataFixture Magento/Sales/_files/invoice.php
91+
* @magentoAppIsolation enabled
9092
*/
9193
public function testAutoGeneratedGetList()
9294
{
@@ -131,6 +133,7 @@ public function testAutoGeneratedGetList()
131133
* Test get list of orders with extension attributes.
132134
*
133135
* @magentoApiDataFixture Magento/Sales/_files/order.php
136+
* @magentoAppIsolation enabled
134137
*/
135138
public function testGetOrdertList()
136139
{

dev/tests/integration/framework/Magento/TestFramework/Application.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,12 @@ public function __construct(
168168
$loadTestExtensionAttributes = false
169169
) {
170170
if (getcwd() != BP . '/dev/tests/integration') {
171+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
171172
chdir(BP . '/dev/tests/integration');
172173
}
173174
$this->_shell = $shell;
174175
$this->installConfigFile = $installConfigFile;
176+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
175177
$this->_globalConfigDir = realpath($globalConfigDir);
176178
$this->_appMode = $appMode;
177179
$this->installDir = $installDir;
@@ -251,6 +253,7 @@ public function getDbInstance()
251253
protected function getInstallConfig()
252254
{
253255
if (null === $this->installConfig) {
256+
// phpcs:ignore Magento2.Security.IncludeFile
254257
$this->installConfig = include $this->installConfigFile;
255258
}
256259
return $this->installConfig;
@@ -293,6 +296,7 @@ public function getInitParams()
293296
*/
294297
public function isInstalled()
295298
{
299+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
296300
return is_file($this->getLocalConfig());
297301
}
298302

@@ -419,11 +423,23 @@ public function initialize($overriddenParams = [])
419423
$sequence = $objectManager->get(\Magento\TestFramework\Db\Sequence::class);
420424
$sequence->generateSequences();
421425
}
422-
426+
$this->createDynamicTables();
423427
$objectManager->create(\Magento\TestFramework\Config::class, ['configPath' => $this->globalConfigFile])
424428
->rewriteAdditionalConfig();
425429
}
426430

431+
/**
432+
* Create dynamic tables
433+
*
434+
* @return void
435+
*/
436+
protected function createDynamicTables()
437+
{
438+
/** @var \Magento\TestFramework\Db\DynamicTables $dynamicTables */
439+
$dynamicTables = Helper\Bootstrap::getObjectManager()->get(\Magento\TestFramework\Db\DynamicTables::class);
440+
$dynamicTables->createTables();
441+
}
442+
427443
/**
428444
* Reset and initialize again an already installed application
429445
*
@@ -552,8 +568,10 @@ private function copyAppConfigFiles()
552568
);
553569
foreach ($globalConfigFiles as $file) {
554570
$targetFile = $this->_configDir . str_replace($this->_globalConfigDir, '', $file);
571+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
555572
$this->_ensureDirExists(dirname($targetFile));
556573
if ($file !== $targetFile) {
574+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
557575
copy($file, $targetFile);
558576
}
559577
}
@@ -567,6 +585,7 @@ private function copyAppConfigFiles()
567585
private function copyGlobalConfigFile()
568586
{
569587
$targetFile = $this->_configDir . '/config.local.php';
588+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
570589
copy($this->globalConfigFile, $targetFile);
571590
}
572591

@@ -636,10 +655,13 @@ protected function _resetApp()
636655
*/
637656
protected function _ensureDirExists($dir)
638657
{
658+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
639659
if (!file_exists($dir)) {
640660
$old = umask(0);
661+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
641662
mkdir($dir, 0777, true);
642663
umask($old);
664+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
643665
} elseif (!is_dir($dir)) {
644666
throw new \Magento\Framework\Exception\LocalizedException(__("'%1' is not a directory.", $dir));
645667
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\TestFramework\Db\DymanicTables;
9+
10+
use Magento\Framework\App\ResourceConnection;
11+
use Magento\Store\Model\Store;
12+
13+
/**
14+
* Class to pre-create category product index tables
15+
*/
16+
class CategoryProductIndexTables
17+
{
18+
19+
/**
20+
* @var string
21+
*/
22+
private $prototype = 'catalog_category_product_index';
23+
24+
/**
25+
* @var ResourceConnection
26+
*/
27+
private $resourceConnection;
28+
29+
/**
30+
* @param ResourceConnection $resourceConnection
31+
*/
32+
public function __construct(
33+
ResourceConnection $resourceConnection
34+
) {
35+
$this->resourceConnection = $resourceConnection;
36+
}
37+
38+
/**
39+
* Creates category product index tables
40+
*/
41+
public function createTables(): void
42+
{
43+
$connection = $this->resourceConnection->getConnection();
44+
for ($storeId = 0; $storeId <= 256; $storeId++) {
45+
$connection->createTable(
46+
$connection->createTableByDdl(
47+
$this->resourceConnection->getTableName($this->prototype),
48+
$this->resourceConnection->getTableName($this->prototype) . '_' . Store::ENTITY . $storeId
49+
)
50+
);
51+
}
52+
}
53+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\TestFramework\Db;
9+
10+
use Magento\TestFramework\Db\DymanicTables\CategoryProductIndexTables;
11+
12+
/**
13+
* Class to pre-create dynamic tables
14+
*/
15+
class DynamicTables
16+
{
17+
/**
18+
* @var CategoryProductIndexTables
19+
*/
20+
private $categoryProductIndexTables;
21+
22+
/**
23+
* @param CategoryProductIndexTables $categoryProductIndexTables
24+
*/
25+
public function __construct(
26+
CategoryProductIndexTables $categoryProductIndexTables
27+
) {
28+
$this->categoryProductIndexTables = $categoryProductIndexTables;
29+
}
30+
31+
/**
32+
* Create dynamic tables before the test to preserve integration tests isolation
33+
*/
34+
public function createTables()
35+
{
36+
$this->categoryProductIndexTables->createTables();
37+
}
38+
}

dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractBackendController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\TestFramework\TestCase;
77

8+
use Magento\Framework\Authorization;
9+
use Magento\TestFramework\ObjectManager;
10+
811
/**
912
* A parent class for backend controllers - contains directives for admin user creation and authentication.
1013
*
@@ -63,7 +66,7 @@ protected function setUp(): void
6366
* If it will be created on test bootstrap we will have invalid RoleLocator object.
6467
* As tests by default are run not from adminhtml area...
6568
*/
66-
\Magento\TestFramework\ObjectManager::getInstance()->removeSharedInstance(\Magento\Framework\Authorization::class);
69+
ObjectManager::getInstance()->removeSharedInstance(Authorization::class);
6770
$this->_auth = $this->_objectManager->get(\Magento\Backend\Model\Auth::class);
6871
$this->_session = $this->_auth->getAuthStorage();
6972
$credentials = $this->_getAdminCredentials();

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ public function testAlreadyExistsExceptionProcessingWhenGroupCodeIsDuplicated():
224224
*/
225225
public function testRemoveAttributeFromAttributeSet(): void
226226
{
227+
$this->markTestSkipped('ECP-739');
227228
$message = 'Attempt to load value of nonexistent EAV attribute';
228229
$this->removeSyslog();
229230
$attributeSet = $this->getAttributeSetByName('new_attribute_set');
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
$appDir = dirname(\Magento\TestFramework\Helper\Bootstrap::getInstance()->getAppTempDir());
8+
// phpcs:ignore Magento2.Security.InsecureFunction
9+
exec("php -f {$appDir}/bin/magento indexer:reindex");

dev/tests/integration/testsuite/Magento/Sales/_files/quote.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('frontend');
8+
9+
$storeManager = Magento\TestFramework\Helper\Bootstrap::getObjectManager()
10+
->get(\Magento\Store\Model\StoreManagerInterface::class);
711
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class);
812
$product->setTypeId('simple')
913
->setId(1)
@@ -23,7 +27,9 @@
2327
'is_in_stock' => 1,
2428
'manage_stock' => 1,
2529
]
26-
)->save();
30+
)
31+
->setWebsiteIds([$storeManager->getStore()->getWebsiteId()])
32+
->save();
2733

2834
$productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
2935
->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
@@ -39,9 +45,7 @@
3945
$shippingAddress = clone $billingAddress;
4046
$shippingAddress->setId(null)->setAddressType('shipping');
4147

42-
$store = Magento\TestFramework\Helper\Bootstrap::getObjectManager()
43-
->get(\Magento\Store\Model\StoreManagerInterface::class)
44-
->getStore();
48+
$store = $storeManager->getStore();
4549

4650
/** @var \Magento\Quote\Model\Quote $quote */
4751
$quote = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Quote\Model\Quote::class);

dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,3 @@
3838
$indexer = Bootstrap::getObjectManager()->create(\Magento\Indexer\Model\Indexer::class);
3939
$indexer->load('catalog_product_price');
4040
$indexer->reindexList([$product->getId()]);
41-

dev/tests/setup-integration/framework/Magento/TestFramework/SetupApplication.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,21 @@ class SetupApplication extends Application
2828
protected $canInstallSequence = false;
2929

3030
/**
31-
* {@inheritdoc}
31+
* @inheritdoc
3232
*/
3333
public function run()
3434
{
35+
// phpcs:ignore Magento2.Exceptions.DirectThrow
3536
throw new \Exception("Can't start application.");
3637
}
38+
39+
/**
40+
* Create dynamic tables
41+
*
42+
* @return null
43+
*/
44+
protected function createDynamicTables()
45+
{
46+
return null;
47+
}
3748
}

dev/tests/static/framework/Magento/TestFramework/Dependency/DbRule.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
*/
88
namespace Magento\TestFramework\Dependency;
99

10+
/**
11+
* Class to get DB dependencies information
12+
*/
1013
class DbRule implements \Magento\TestFramework\Dependency\RuleInterface
1114
{
1215
/**
@@ -37,7 +40,7 @@ public function __construct(array $tables)
3740
*/
3841
public function getDependencyInfo($currentModule, $fileType, $file, &$contents)
3942
{
40-
if ('php' != $fileType || !preg_match('#.*/(Setup|Resource)/.*\.php$#', $file)) {
43+
if ('php' != $fileType || !preg_match('#.*/(Setup|Resource|Query)/.*\.php$#', $file)) {
4144
return [];
4245
}
4346

dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,19 @@ public function testCodeStyle()
326326
touch($reportFile);
327327
}
328328
$codeSniffer = new CodeSniffer('Magento', $reportFile, new Wrapper());
329-
$result = $codeSniffer->run(
330-
$this->isFullScan() ? $this->getFullWhitelist() : self::getWhitelist(['php', 'phtml'])
331-
);
329+
$fileList = $this->isFullScan() ? $this->getFullWhitelist() : self::getWhitelist(['php', 'phtml']);
330+
$ignoreList = Files::init()->readLists(__DIR__ . '/_files/phpcs/ignorelist/*.txt');
331+
if ($ignoreList) {
332+
$ignoreListPattern = sprintf('#(%s)#i', implode('|', $ignoreList));
333+
$fileList = array_filter(
334+
$fileList,
335+
function ($path) use ($ignoreListPattern) {
336+
return !preg_match($ignoreListPattern, $path);
337+
}
338+
);
339+
}
340+
341+
$result = $codeSniffer->run($fileList);
332342
$report = file_get_contents($reportFile);
333343
$this->assertEquals(
334344
0,
@@ -348,8 +358,19 @@ public function testCodeMess()
348358
if (!$codeMessDetector->canRun()) {
349359
$this->markTestSkipped('PHP Mess Detector is not available.');
350360
}
361+
$fileList = self::getWhitelist(['php']);
362+
$ignoreList = Files::init()->readLists(__DIR__ . '/_files/phpmd/ignorelist/*.txt');
363+
if ($ignoreList) {
364+
$ignoreListPattern = sprintf('#(%s)#i', implode('|', $ignoreList));
365+
$fileList = array_filter(
366+
$fileList,
367+
function ($path) use ($ignoreListPattern) {
368+
return !preg_match($ignoreListPattern, $path);
369+
}
370+
);
371+
}
351372

352-
$result = $codeMessDetector->run(self::getWhitelist(['php']));
373+
$result = $codeMessDetector->run($fileList);
353374

354375
$output = "";
355376
if (file_exists($reportFile)) {

0 commit comments

Comments
 (0)