Skip to content
This repository was archived by the owner on Feb 15, 2023. It is now read-only.

Commit 552e0b2

Browse files
committed
More tests and edge cases.
1 parent 3579f34 commit 552e0b2

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

platformsh-flex-env.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function mapPlatformShDatabase() : void
6060
switch ($endpoint['scheme']) {
6161
case 'mysql':
6262
// Defaults to the latest MariaDB version
63-
$dbUrl .= '?serverVersion=10.2&charset=utf8mb4';
63+
$dbUrl .= '?charset=utf8mb4&serverVersion=10.2';
6464
break;
6565

6666
case 'pgsql':

tests/FlexBridgeDatabaseTest.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ public function setUp()
1818

1919
$this->relationships = [
2020
'database' => [
21-
'scheme' => 'mysql',
22-
'username' => 'user',
23-
'password' => '',
24-
'host' => 'database.internal',
25-
'port' => '3306',
26-
'path' => 'main',
27-
'query' => ['is_master' => true],
21+
[
22+
'scheme' => 'mysql',
23+
'username' => 'user',
24+
'password' => '',
25+
'host' => 'database.internal',
26+
'port' => '3306',
27+
'path' => 'main',
28+
'query' => ['is_master' => true],
29+
]
2830
]
2931
];
3032

@@ -67,11 +69,21 @@ public function testNoDatabaseRelationship()
6769
$rels = $this->relationships;
6870
unset($rels['database']);
6971

70-
putenv(sprintf('PLATFORM_RELATIONSHIPS=%s', base64_encode(json_encode($this->relationships))));
72+
putenv(sprintf('PLATFORM_RELATIONSHIPS=%s', base64_encode(json_encode($rels))));
7173

7274
mapPlatformShEnvironment();
7375

7476
$this->assertEquals($this->defaultDbUrl, $_SERVER['DATABASE_URL']);
7577
}
7678

79+
public function testDatabaseRelationshipSet()
80+
{
81+
putenv('PLATFORM_APPLICATION=test');
82+
putenv(sprintf('PLATFORM_RELATIONSHIPS=%s', base64_encode(json_encode($this->relationships))));
83+
84+
mapPlatformShEnvironment();
85+
86+
$this->assertEquals('mysql://user:@database.internal:3306/main?charset=utf8mb4&serverVersion=10.2', $_SERVER['DATABASE_URL']);
87+
}
88+
7789
}

0 commit comments

Comments
 (0)