Skip to content

Commit 4f72495

Browse files
committed
ACP2E-4367: Incompatibility with MariaDB 10.11
1 parent d40d4a5 commit 4f72495

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Framework\DB\Test\Unit\Adapter;
9+
10+
use Magento\Framework\App\ResourceConnection;
11+
use Magento\Framework\DB\Adapter\AdapterInterface;
12+
use Magento\Framework\DB\Adapter\SqlVersionProvider;
13+
use PHPUnit\Framework\MockObject\MockObject;
14+
use PHPUnit\Framework\TestCase;
15+
16+
class SqlVersionProviderTest extends TestCase
17+
{
18+
/**
19+
* @var ResourceConnection|MockObject
20+
*/
21+
private ResourceConnection $resourceConnection;
22+
23+
/**
24+
* @var SqlVersionProvider
25+
*/
26+
private SqlVersionProvider $sqlVersionProvider;
27+
28+
protected function setUp(): void
29+
{
30+
$this->resourceConnection = $this->createMock(ResourceConnection::class);
31+
$this->sqlVersionProvider = new SqlVersionProvider(
32+
$this->resourceConnection,
33+
[
34+
'^8\.0\.',
35+
'^8\.4\.',
36+
'^5\.7\.',
37+
'^10\.(?:[2-6]|11)\.',
38+
'^11\.4\.'
39+
]
40+
);
41+
}
42+
43+
/**
44+
* @dataProvider mariaDbSuffixKeyDataProvider
45+
*/
46+
public function testGetMariaDbSuffixKey(
47+
string $sqlVersionString,
48+
string $sqlExactVersion,
49+
string $expectedSuffixKey
50+
): void {
51+
$adapter = $this->createMock(AdapterInterface::class);
52+
$adapter->expects($this->exactly(2))->method('fetchPairs')->willReturn(
53+
['version' => $sqlExactVersion]
54+
);
55+
$this->resourceConnection->expects($this->any())
56+
->method('getConnection')
57+
->willReturn($adapter);
58+
59+
$this->assertSame(
60+
$expectedSuffixKey,
61+
$this->sqlVersionProvider->getMariaDbSuffixKey()
62+
);
63+
}
64+
65+
/**
66+
* Covers:
67+
* - default fallback
68+
* - 10.4.x branch
69+
* - 10.6.x branch
70+
* - 11.4.x branch mapping to 10.6.11 suffix
71+
* - 10.11.x branch
72+
*/
73+
public static function mariaDbSuffixKeyDataProvider(): array
74+
{
75+
return [
76+
'version below threshold uses default suffix (10.6.11)' => [
77+
'sqlVersionString' => 'MariaDB-10.2.44',
78+
// < 10.4.27 → outer if not entered → default suffix
79+
'sqlExactVersion' => '10.2.44',
80+
'expectedSuffixKey' => SqlVersionProvider::MARIA_DB_10_6_11_VERSION,
81+
],
82+
'MariaDB 10.4.x at/above 10.4.27 uses 10.4.27 suffix' => [
83+
'sqlVersionString' => SqlVersionProvider::MARIA_DB_10_4_VERSION, // e.g. "MariaDB-10.4"
84+
'sqlExactVersion' => '10.4.27',
85+
'expectedSuffixKey' => SqlVersionProvider::MARIA_DB_10_4_27_VERSION,
86+
],
87+
'MariaDB 10.6.x at/above 10.4.27 uses 10.6.11 suffix' => [
88+
'sqlVersionString' => SqlVersionProvider::MARIA_DB_10_6_VERSION, // e.g. "MariaDB-10.6"
89+
'sqlExactVersion' => '10.6.11',
90+
'expectedSuffixKey' => SqlVersionProvider::MARIA_DB_10_6_11_VERSION,
91+
],
92+
'MariaDB 11.4.x at/above threshold maps to 10.6.11 suffix' => [
93+
'sqlVersionString' => SqlVersionProvider::MARIA_DB_11_4_VERSION, // e.g. "MariaDB-11.4"
94+
'sqlExactVersion' => '11.4.3',
95+
// branch: $isMariaDB114 → return 10.6.11 suffix
96+
'expectedSuffixKey' => SqlVersionProvider::MARIA_DB_10_6_11_VERSION,
97+
],
98+
'MariaDB 10.11.x at/above threshold uses 10.11 suffix' => [
99+
'sqlVersionString' => SqlVersionProvider::MARIA_DB_10_11_VERSION, // e.g. "MariaDB-10.11"
100+
'sqlExactVersion' => '10.11.6',
101+
'expectedSuffixKey' => SqlVersionProvider::MARIA_DB_10_11_VERSION,
102+
],
103+
];
104+
}
105+
}

0 commit comments

Comments
 (0)