Skip to content

Commit bcaea60

Browse files
authored
Merge branch '2.4.5-develop' into DHL-AC-3145-JUNE-3-2022
2 parents e55d937 + 74ff88e commit bcaea60

File tree

7 files changed

+146
-15
lines changed

7 files changed

+146
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminExportSimpleProductWithImageAndImageAltForDiffrentScopeTest">
12+
13+
<helper class="Magento\AwsS3\Test\Mftf\Helper\FileAssertions" method="assertFileExists" stepKey="assertExportFileExists">
14+
<argument name="filePath">{"local":"var/export/{$grabNameFile}","s3":"import_export/export/{$grabNameFile}"}</argument>
15+
</helper>
16+
<helper class="Magento\AwsS3\Test\Mftf\Helper\FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsConfigurableProduct">
17+
<argument name="filePath">{"local":"var/export/{$grabNameFile}","s3":"import_export/export/{$grabNameFile}"}</argument>
18+
<argument name="text">$createProductImage.entry[content][name]$,"english image alt text 1"</argument>
19+
</helper>
20+
<helper class="Magento\AwsS3\Test\Mftf\Helper\FileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsConfigurableProduct1">
21+
<argument name="filePath">{"local":"var/export/{$grabNameFile}","s3":"import_export/export/{$grabNameFile}"}</argument>
22+
<argument name="text">$createProductImage.entry[content][name]$,"french image alt text 1"</argument>
23+
</helper>
24+
</test>
25+
</tests>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminImportSimpleProductImageLongNameTest">
12+
13+
<before>
14+
<!-- Copy Images to Import Directory for Product Images -->
15+
<helper class="Magento\AwsS3\Test\Mftf\Helper\FileAssertions" method="createDirectory" stepKey="createDirectoryForImportImages">
16+
<argument name="path">var/import/images/test_image_long_name</argument>
17+
</helper>
18+
<helper class="Magento\AwsS3\Test\Mftf\Helper\FileAssertions" method="copyFromLocal" stepKey="copyProductBaseImage">
19+
<argument name="source">dev/tests/acceptance/tests/_data/{{placeholderBaseImageLongName.file}}</argument>
20+
<argument name="destination">var/import/images/test_image_long_name/{{placeholderBaseImageLongName.file}}</argument>
21+
</helper>
22+
</before>
23+
24+
<after>
25+
<helper class="Magento\AwsS3\Test\Mftf\Helper\FileAssertions" method="deleteDirectory" stepKey="deleteProductImageDirectory">
26+
<argument name="path">var/import/images/test_image_long_name</argument>
27+
</helper>
28+
</after>
29+
30+
</test>
31+
</tests>

app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/NewConditionHtml.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ class NewConditionHtml extends Quote implements HttpPostActionInterface
2222
*/
2323
public function execute()
2424
{
25-
$id = $this->getRequest()->getParam('id');
2625
$formName = $this->getRequest()->getParam('form_namespace');
27-
$typeArr = explode(
26+
$id = $this->getRequest()->getParam('id');
27+
$typeArray = explode(
2828
'|',
2929
str_replace('-', '/', $this->getRequest()->getParam('type', ''))
3030
);
31-
$type = $typeArr[0];
31+
$type = $typeArray[0];
3232

33-
if (class_exists($type) && !in_array(ConditionInterface::class, class_implements($type))) {
33+
if ($type && class_exists($type) && !in_array(ConditionInterface::class, class_implements($type))) {
3434
$html = '';
3535
$this->getResponse()->setBody($html);
3636
return;
@@ -47,8 +47,8 @@ public function execute()
4747
)->setPrefix(
4848
'conditions'
4949
);
50-
if (!empty($typeArr[1])) {
51-
$model->setAttribute($typeArr[1]);
50+
if (!empty($typeArray[1])) {
51+
$model->setAttribute($typeArray[1]);
5252
}
5353

5454
if ($model instanceof AbstractCondition) {

app/code/Magento/Swatches/Test/Mftf/Test/StorefrontConfigurableOptionsImportSameBaseImageTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
(visible and active) for each selected option for the configurable product"/>
1818
<severity value="MAJOR"/>
1919
<group value="swatches"/>
20+
<group value="skip_in_cloud_native_s3"/>
2021
</annotations>
2122
<before>
2223
<!-- Login as Admin -->

dev/tests/setup-integration/framework/Magento/TestFramework/TestCase/SetupTestCase.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77

88
namespace Magento\TestFramework\TestCase;
99

10+
use Magento\Framework\App\ResourceConnection;
1011
use Magento\Framework\DB\Adapter\ConnectionException;
1112
use Magento\Framework\DB\Adapter\SqlVersionProvider;
1213
use Magento\TestFramework\Annotation\DataProviderFromFile;
1314
use Magento\TestFramework\Helper\Bootstrap;
15+
use Zend_Db_Statement_Exception;
1416

1517
/**
1618
* Instance of Setup test case. Used in order to tweak dataProviders functionality.
@@ -32,17 +34,25 @@ class SetupTestCase extends \PHPUnit\Framework\TestCase implements MutableDataIn
3234
*/
3335
private $sqlVersionProvider;
3436

37+
/**
38+
* @var ResourceConnection
39+
*/
40+
private ResourceConnection $resourceConnection;
41+
3542
/**
3643
* @inheritDoc
3744
*/
3845
public function __construct(
3946
$name = null,
4047
array $data = [],
41-
$dataName = ''
48+
$dataName = '',
49+
ResourceConnection $resourceConnection = null
4250
) {
4351
parent::__construct($name, $data, $dataName);
4452

45-
$this->sqlVersionProvider = Bootstrap::getObjectManager()->get(SqlVersionProvider::class);
53+
$objectManager = Bootstrap::getObjectManager();
54+
$this->sqlVersionProvider = $objectManager->get(SqlVersionProvider::class);
55+
$this->resourceConnection = $resourceConnection ?? $objectManager->get(ResourceConnection::class);
4656
}
4757

4858
/**
@@ -105,4 +115,20 @@ private function getDbKey(): string
105115

106116
return $this->dbKey;
107117
}
118+
119+
/**
120+
* Checks if the DB connection Aurora RDS
121+
*
122+
* @param string $resource
123+
* @return bool
124+
*/
125+
public function isUsingAuroraDb(string $resource = ResourceConnection::DEFAULT_CONNECTION): bool
126+
{
127+
try {
128+
$this->resourceConnection->getConnection($resource)->query('SELECT AURORA_VERSION();');
129+
return true;
130+
} catch (Zend_Db_Statement_Exception $e) {
131+
return false;
132+
}
133+
}
108134
}

dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public function testInstallationWithConstraintsModification()
216216
);
217217
self::assertNull($diff->getAll());
218218
$shardData = $this->describeTable->describeShard(Sharding::DEFAULT_CONNECTION);
219-
self::assertEquals($this->getTrimmedData(), $shardData);
219+
$this->assertTableCreationStatements($this->getTrimmedData(), $shardData);
220220
}
221221

222222
/**
@@ -246,7 +246,7 @@ public function testInstallationWithDroppingTables()
246246
);
247247
self::assertNull($diff->getAll());
248248
$shardData = $this->describeTable->describeShard(Sharding::DEFAULT_CONNECTION);
249-
self::assertEquals($this->getData(), $shardData);
249+
$this->assertTableCreationStatements($this->getData(), $shardData);
250250
}
251251

252252
/**
@@ -305,6 +305,10 @@ public function testInstallWithCodeBaseRollback()
305305
$this->cliCommand->install(
306306
['Magento_TestSetupDeclarationModule1']
307307
);
308+
309+
if ($this->isUsingAuroraDb()) {
310+
$this->markTestSkipped('Test skipped in AWS Aurora');
311+
}
308312
$beforeRollback = $this->describeTable->describeShard('default');
309313
self::assertEquals($this->getTrimmedData()['before'], $beforeRollback);
310314
//Move db_schema.xml file and tried to install
@@ -344,7 +348,9 @@ public function testTableRename()
344348
$this->resourceConnection->getTableName('some_table'),
345349
$dataToMigrate
346350
);
347-
self::assertEquals($this->getData()['before'], $before['some_table']);
351+
$this->isUsingAuroraDb() ?
352+
$this->assertStringContainsString($before['some_table'], $this->getTrimmedData()['before']) :
353+
$this->assertEquals($this->getData()['before'], $before['some_table']);
348354
//Move db_schema.xml file and tried to install
349355
$this->moduleManager->updateRevision(
350356
'Magento_TestSetupDeclarationModule1',
@@ -355,7 +361,9 @@ public function testTableRename()
355361

356362
$this->cliCommand->upgrade();
357363
$after = $this->describeTable->describeShard('default');
358-
self::assertEquals($this->getData()['after'], $after['some_table_renamed']);
364+
$this->isUsingAuroraDb() ?
365+
$this->assertStringContainsString($after['some_table_renamed'], $this->getTrimmedData()['after']) :
366+
$this->assertEquals($this->getData()['after'], $after['some_table_renamed']);
359367
$select = $adapter->select()
360368
->from($this->resourceConnection->getTableName('some_table_renamed'));
361369
self::assertEquals([$dataToMigrate], $adapter->fetchAll($select));
@@ -459,6 +467,26 @@ public function testInstallationWithDisablingTables()
459467
);
460468
self::assertNull($diff->getAll());
461469
$shardData = $this->describeTable->describeShard(Sharding::DEFAULT_CONNECTION);
462-
self::assertEquals($this->getData(), $shardData);
470+
$this->assertTableCreationStatements($this->getData(), $shardData);
471+
}
472+
473+
/**
474+
* Assert table creation statements
475+
*
476+
* @param array $expectedData
477+
* @param array $actualData
478+
*/
479+
private function assertTableCreationStatements(array $expectedData, array $actualData): void
480+
{
481+
if (!$this->isUsingAuroraDb()) {
482+
$this->assertEquals($expectedData, $actualData);
483+
} else {
484+
ksort($expectedData);
485+
ksort($actualData);
486+
$this->assertSameSize($expectedData, $actualData);
487+
foreach ($expectedData as $key => $value) {
488+
$this->assertStringContainsString($actualData[$key], $value);
489+
}
490+
}
463491
}
464492
}

dev/tests/setup-integration/testsuite/Magento/Setup/ShardingTest.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function testInstall()
7878
self::assertCount(2, $default);
7979
self::assertCount(1, $shard1);
8080
self::assertCount(1, $shard2);
81-
self::assertEquals($this->getData(), array_replace($default, $shard1, $shard2));
81+
$this->assertTableCreationStatements($this->getData(), array_replace($default, $shard1, $shard2));
8282
}
8383

8484
/**
@@ -99,6 +99,26 @@ public function testUpgrade()
9999
self::assertCount(2, $default);
100100
self::assertCount(1, $shard1);
101101
self::assertCount(1, $shard2);
102-
self::assertEquals($this->getData(), array_replace($default, $shard1, $shard2));
102+
$this->assertTableCreationStatements($this->getData(), array_replace($default, $shard1, $shard2));
103+
}
104+
105+
/**
106+
* Assert table creation statements
107+
*
108+
* @param array $expectedData
109+
* @param array $actualData
110+
*/
111+
private function assertTableCreationStatements(array $expectedData, array $actualData): void
112+
{
113+
if (!$this->isUsingAuroraDb()) {
114+
$this->assertEquals($expectedData, $actualData);
115+
} else {
116+
ksort($expectedData);
117+
ksort($actualData);
118+
$this->assertSameSize($expectedData, $actualData);
119+
foreach ($expectedData as $key => $value) {
120+
$this->assertStringContainsString($actualData[$key], $value);
121+
}
122+
}
103123
}
104124
}

0 commit comments

Comments
 (0)