Skip to content

Commit 3018b06

Browse files
authored
Merge pull request #5927 from magento-trigger/MC-35778
[TR] Integration failures on Magento 2.3-develop with MariaDB 10.2
2 parents e27d322 + 70b474a commit 3018b06

File tree

13 files changed

+503
-13
lines changed

13 files changed

+503
-13
lines changed

app/code/Magento/Paypal/Test/Mftf/ActionGroup/PayPalExpressCheckoutConfigurationActionGroup.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
<switchToNextTab stepKey="switchToInContentTab"/>
8484
<waitForPageLoad stepKey="waitForPageLoad"/>
8585
<seeCurrentUrlMatches regex="~\//www.sandbox.paypal.com/~" stepKey="seeCurrentUrlMatchesConfigPath1"/>
86+
<conditionalClick selector="{{PayPalPaymentSection.existingAccountLoginBtn}}" dependentSelector="{{PayPalPaymentSection.existingAccountLoginBtn}}" visible="true" stepKey="skipAccountCreationAndLogin"/>
87+
<waitForPageLoad stepKey="waitForLoginPageLoad"/>
8688
<waitForElement selector="{{PayPalPaymentSection.email}}" stepKey="waitForLoginForm" />
8789
<fillField selector="{{PayPalPaymentSection.email}}" userInput="{{credentials.magento/paypal_sandbox_login_email}}" stepKey="fillEmail"/>
8890
<fillField selector="{{PayPalPaymentSection.password}}" userInput="{{credentials.magento/paypal_sandbox_login_password}}" stepKey="fillPassword"/>

app/code/Magento/Paypal/Test/Mftf/Section/PayPalExpressCheckoutConfigSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<section name="PayPalPaymentSection">
5555
<element name="guestCheckout" type="input" selector="#guest"/>
5656
<element name="loginSection" type="input" selector=" #main>#login"/>
57+
<element name="existingAccountLoginBtn" type="input" selector="#loginSection a"/>
5758
<element name="email" type="input" selector="//input[contains(@name, 'email') and not(contains(@style, 'display:none'))]"/>
5859
<element name="password" type="input" selector="//input[contains(@name, 'password') and not(contains(@style, 'display:none'))]"/>
5960
<element name="loginBtn" type="input" selector="button#btnLogin"/>

app/code/Magento/Paypal/Test/Mftf/Test/StorefrontPaypalSmartButtonInCheckoutPageTest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
<severity value="CRITICAL"/>
1818
<testCaseId value="MC-13690"/>
1919
<group value="paypal"/>
20-
<skip>
21-
<issueId value="MC-35792"/>
22-
</skip>
2320
</annotations>
2421
<before>
2522

app/etc/di.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,4 +1809,12 @@
18091809
<argument name="cache" xsi:type="object">configured_block_cache</argument>
18101810
</arguments>
18111811
</type>
1812+
<type name="Magento\Framework\DB\Adapter\SqlVersionProvider">
1813+
<arguments>
1814+
<argument name="supportedVersionPatterns" xsi:type="array">
1815+
<item name="MySQL-(5.6,5.7)" xsi:type="string">^5\.[67]\.</item>
1816+
<item name="MariaDB-(10.0-10.2)" xsi:type="string">^10\.[0-2]\.</item>
1817+
</argument>
1818+
</arguments>
1819+
</type>
18121820
</config>

dev/tests/integration/testsuite/Magento/Framework/DB/Adapter/Pdo/MysqlTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Framework\DB\Adapter\Pdo;
77

88
use Magento\Framework\App\ResourceConnection;
9+
use Magento\Framework\Exception\LocalizedException;
910
use Magento\TestFramework\Helper\CacheCleaner;
1011
use Magento\Framework\DB\Ddl\Table;
1112
use Magento\TestFramework\Helper\Bootstrap;
@@ -80,7 +81,7 @@ private function setWaitTimeout($waitTimeout)
8081
*
8182
* @param $sql
8283
* @return void|\Zend_Db_Statement_Pdo
83-
* @throws \Magento\Framework\Exception\LocalizedException
84+
* @throws LocalizedException
8485
* @throws \Zend_Db_Adapter_Exception
8586
*/
8687
private function executeQuery($sql)
@@ -187,7 +188,11 @@ public function testCreateTableColumnWithExpressionAsColumnDefaultValue()
187188
//Test default value with expression
188189
$this->assertEquals('created_at', $dateColumn['COLUMN_NAME'], 'Incorrect column name');
189190
$this->assertEquals(Table::TYPE_DATETIME, $dateColumn['DATA_TYPE'], 'Incorrect column type');
190-
$this->assertEquals('CURRENT_TIMESTAMP', $dateColumn['DEFAULT'], 'Incorrect column default expression value');
191+
$this->assertRegExp(
192+
'/^(CURRENT_TIMESTAMP|current_timestamp\(\))$/',
193+
$dateColumn['DEFAULT'],
194+
'Incorrect column default expression value'
195+
);
191196

192197
//Test default value with integer value
193198
$this->assertEquals('integer_column', $intColumn['COLUMN_NAME'], 'Incorrect column name');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
return [
7+
'auto_increment_test' => 'CREATE TABLE `auto_increment_test` (
8+
`int_auto_increment_with_nullable` int(12) unsigned NOT NULL AUTO_INCREMENT,
9+
`int_disabled_auto_increment` smallint(12) unsigned DEFAULT 0,
10+
UNIQUE KEY `AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE` (`int_auto_increment_with_nullable`)
11+
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
12+
'reference_table' => 'CREATE TABLE `reference_table` (
13+
`tinyint_ref` tinyint(7) NOT NULL AUTO_INCREMENT,
14+
`tinyint_without_padding` tinyint(2) NOT NULL DEFAULT 0,
15+
`bigint_without_padding` bigint(20) NOT NULL DEFAULT 0,
16+
`smallint_without_padding` smallint(5) NOT NULL DEFAULT 0,
17+
`integer_without_padding` int(11) NOT NULL DEFAULT 0,
18+
`smallint_with_big_padding` smallint(254) NOT NULL DEFAULT 0,
19+
`smallint_without_default` smallint(2) DEFAULT NULL,
20+
`int_without_unsigned` int(2) DEFAULT NULL,
21+
`int_unsigned` int(2) unsigned DEFAULT NULL,
22+
`bigint_default_nullable` bigint(2) unsigned DEFAULT 1,
23+
`bigint_not_default_not_nullable` bigint(2) unsigned NOT NULL,
24+
`smallint_ref` smallint(254) NOT NULL DEFAULT 0,
25+
PRIMARY KEY (`tinyint_ref`,`smallint_ref`),
26+
UNIQUE KEY `REFERENCE_TABLE_SMALLINT_REF` (`smallint_ref`)
27+
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
28+
'test_table' => 'CREATE TABLE `test_table` (
29+
`smallint` smallint(3) DEFAULT NULL,
30+
`tinyint` tinyint(7) DEFAULT NULL,
31+
`bigint` bigint(13) DEFAULT 0,
32+
`float` float(12,10) DEFAULT 0.0000000000,
33+
`double` double(245,10) DEFAULT 11111111.1111110000,
34+
`decimal` decimal(15,4) DEFAULT 0.0000,
35+
`date` date DEFAULT NULL,
36+
`timestamp` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
37+
`datetime` datetime DEFAULT \'0000-00-00 00:00:00\',
38+
`longtext` longtext DEFAULT NULL,
39+
`mediumtext` mediumtext DEFAULT NULL,
40+
`varchar` varchar(254) DEFAULT NULL,
41+
`mediumblob` mediumblob DEFAULT NULL,
42+
`blob` blob DEFAULT NULL,
43+
`boolean` tinyint(1) DEFAULT NULL,
44+
`integer_main` int(12) unsigned DEFAULT NULL,
45+
`smallint_main` smallint(254) NOT NULL DEFAULT 0,
46+
UNIQUE KEY `TEST_TABLE_SMALLINT_FLOAT` (`smallint`,`float`),
47+
UNIQUE KEY `TEST_TABLE_DOUBLE` (`double`),
48+
KEY `TEST_TABLE_TINYINT_BIGINT` (`tinyint`,`bigint`),
49+
KEY `TEST_TABLE_SMALLINT_MAIN_REFERENCE_TABLE_SMALLINT_REF` (`smallint_main`),
50+
KEY `FK_FB77604C299EB8612D01E4AF8D9931F2` (`integer_main`),
51+
CONSTRAINT `FK_FB77604C299EB8612D01E4AF8D9931F2` FOREIGN KEY (`integer_main`)'
52+
. ' REFERENCES `auto_increment_test` (`int_auto_increment_with_nullable`) ON DELETE CASCADE,
53+
CONSTRAINT `TEST_TABLE_SMALLINT_MAIN_REFERENCE_TABLE_SMALLINT_REF` FOREIGN KEY (`smallint_main`)'
54+
. ' REFERENCES `reference_table` (`smallint_ref`) ON DELETE CASCADE,
55+
CONSTRAINT `TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF` FOREIGN KEY (`tinyint`)'
56+
. ' REFERENCES `reference_table` (`tinyint_ref`) ON DELETE SET NULL
57+
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
58+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
return [
7+
'auto_increment_test' => 'CREATE TABLE `auto_increment_test` (
8+
`int_auto_increment_with_nullable` int(12) unsigned NOT NULL AUTO_INCREMENT,
9+
`int_disabled_auto_increment` smallint(12) unsigned DEFAULT 0,
10+
UNIQUE KEY `AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE` (`int_auto_increment_with_nullable`)
11+
) ENGINE=InnoDB DEFAULT CHARSET=utf8'
12+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
return [
9+
'auto_increment_test' => 'CREATE TABLE `auto_increment_test` (
10+
`int_auto_increment_with_nullable` int(12) unsigned NOT NULL AUTO_INCREMENT,
11+
`int_disabled_auto_increment` smallint(12) unsigned DEFAULT 0,
12+
UNIQUE KEY `AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE` (`int_auto_increment_with_nullable`)
13+
) ENGINE=InnoDB DEFAULT CHARSET=utf8'
14+
];

dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/DataProviderFromFile.php

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\TestFramework\Annotation;
810

11+
use Magento\Framework\DB\Adapter\SqlVersionProvider;
912
use Magento\TestFramework\Deploy\CliCommand;
1013
use Magento\TestFramework\Deploy\TestModuleManager;
1114
use Magento\TestFramework\TestCase\MutableDataInterface;
@@ -15,6 +18,18 @@
1518
*/
1619
class DataProviderFromFile
1720
{
21+
/**
22+
* @var string
23+
*/
24+
const FALLBACK_VALUE = 'default';
25+
26+
/**
27+
* @var array
28+
*/
29+
const POSSIBLE_SUFFIXES = [
30+
SqlVersionProvider::MARIA_DB_10_VERSION => 'mariadb10',
31+
];
32+
1833
/**
1934
* @var TestModuleManager
2035
*/
@@ -45,9 +60,10 @@ public function startTest(\PHPUnit\Framework\TestCase $test)
4560
$annotations = $test->getAnnotations();
4661
//This annotation can be declared only on method level
4762
if (isset($annotations['method']['dataProviderFromFile']) && $test instanceof MutableDataInterface) {
48-
$data = include TESTS_MODULES_PATH . "/" . $annotations['method']['dataProviderFromFile'][0];
49-
$test->setData($data);
50-
} else if (!$test instanceof MutableDataInterface) {
63+
$test->setData(
64+
$this->loadAllFiles(TESTS_MODULES_PATH . "/" . $annotations['method']['dataProviderFromFile'][0])
65+
);
66+
} elseif (!$test instanceof MutableDataInterface) {
5167
throw new \Exception("Test type do not supports @dataProviderFromFile annotation");
5268
}
5369
}
@@ -64,4 +80,61 @@ public function endTest(\PHPUnit\Framework\TestCase $test)
6480
$test->flushData();
6581
}
6682
}
83+
84+
/**
85+
* Load different db version files for different databases.
86+
*
87+
* @param string $path The path of the initial file.
88+
*
89+
* @return array
90+
*/
91+
private function loadAllFiles(string $path): array
92+
{
93+
$result = [];
94+
$pathWithoutExtension = $this->removeFileExtension($path);
95+
96+
foreach (glob($pathWithoutExtension . '.*') as $file) {
97+
preg_match('/\.([\D]*[\d]*(?:\.[\d]+){0,2})/', $file, $splitParts);
98+
$dbKey = self::FALLBACK_VALUE;
99+
100+
if (count($splitParts) > 1) {
101+
$database = array_pop($splitParts);
102+
103+
if ($this->isValidDatabaseSuffix($database)) {
104+
$dbKey = $database;
105+
}
106+
}
107+
108+
$result[$dbKey] = include $file;
109+
}
110+
111+
return $result;
112+
}
113+
114+
/**
115+
* Remove the file extension from path.
116+
*
117+
* @param string $path The file path.
118+
*
119+
* @return string
120+
*/
121+
private function removeFileExtension(string $path)
122+
{
123+
$result = explode('.', $path);
124+
array_pop($result);
125+
126+
return implode('.', $result);
127+
}
128+
129+
/**
130+
* Check if database suffix is valid.
131+
*
132+
* @param string $databaseSuffix The suffix of the database from the file
133+
*
134+
* @return bool
135+
*/
136+
private function isValidDatabaseSuffix(string $databaseSuffix): bool
137+
{
138+
return in_array($databaseSuffix, self::POSSIBLE_SUFFIXES);
139+
}
67140
}

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

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
declare(strict_types=1);
8+
69
namespace Magento\TestFramework\TestCase;
710

8-
use Magento\Framework\App\DesignInterface;
9-
use Magento\Framework\View\DesignExceptions;
11+
use Magento\Framework\DB\Adapter\ConnectionException;
12+
use Magento\Framework\DB\Adapter\SqlVersionProvider;
13+
use Magento\TestFramework\Annotation\DataProviderFromFile;
14+
use Magento\TestFramework\Helper\Bootstrap;
1015

1116
/**
1217
* Instance of Setup test case. Used in order to tweak dataProviders functionality.
@@ -18,6 +23,25 @@ class SetupTestCase extends \PHPUnit\Framework\TestCase implements MutableDataIn
1823
*/
1924
private $data = [];
2025

26+
/**
27+
* @var string
28+
*/
29+
private $dbKey;
30+
31+
/**
32+
* @var SqlVersionProvider
33+
*/
34+
private $sqlVersionProvider;
35+
36+
/**
37+
* @inheritDoc
38+
*/
39+
public function __construct($name = null, array $data = [], $dataName = '')
40+
{
41+
parent::__construct($name, $data, $dataName);
42+
$this->sqlVersionProvider = Bootstrap::getObjectManager()->get(SqlVersionProvider::class);
43+
}
44+
2145
/**
2246
* @inheritdoc
2347
*/
@@ -36,9 +60,45 @@ public function flushData()
3660

3761
/**
3862
* @inheritdoc
63+
*
64+
* @throws ConnectionException
3965
*/
4066
public function getData()
4167
{
42-
return $this->data;
68+
return $this->data[$this->getDbKey()] ?? $this->data[DataProviderFromFile::FALLBACK_VALUE];
69+
}
70+
71+
/**
72+
* Get database version.
73+
*
74+
* @return string
75+
* @throws ConnectionException
76+
*/
77+
protected function getDatabaseVersion(): string
78+
{
79+
return $this->sqlVersionProvider->getSqlVersion();
80+
}
81+
82+
/**
83+
* Get db key to decide which file to use.
84+
*
85+
* @return string
86+
* @throws ConnectionException
87+
*/
88+
private function getDbKey(): string
89+
{
90+
if ($this->dbKey) {
91+
return $this->dbKey;
92+
}
93+
94+
$this->dbKey = DataProviderFromFile::FALLBACK_VALUE;
95+
foreach (DataProviderFromFile::POSSIBLE_SUFFIXES as $possibleVersion => $suffix) {
96+
if (strpos($this->getDatabaseVersion(), (string)$possibleVersion) !== false) {
97+
$this->dbKey = $suffix;
98+
break;
99+
}
100+
}
101+
102+
return $this->dbKey;
43103
}
44104
}

0 commit comments

Comments
 (0)