Skip to content

Commit d24854c

Browse files
IBX-10159: Corrected generate dfs_database_url parameter for Ibexa Cloud (#595)
1 parent bdce6c0 commit d24854c

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

src/bundle/Core/DependencyInjection/IbexaCoreExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,12 +861,12 @@ private function configurePlatformShSetup(ContainerBuilder $container): void
861861
$container->setParameter(
862862
'dfs_database_url',
863863
sprintf(
864-
'%s://%s:%s:%d@%s/%s',
864+
'%s://%s:%s@%s:%d/%s',
865865
$endpoint['scheme'],
866866
$endpoint['username'],
867867
$endpoint['password'],
868-
$endpoint['port'],
869868
$endpoint['host'],
869+
$endpoint['port'],
870870
$endpoint['path']
871871
)
872872
);

tests/bundle/Core/DependencyInjection/IbexaCoreExtensionTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,51 @@ public function testLoadsTestServicesWhenParameterIsSpecified(): void
910910
$this->assertContainerBuilderHasService(QueryControllerContext::class);
911911
}
912912

913+
/**
914+
* @throws \JsonException
915+
*/
916+
public function testConfigurePlatformShDFS(): void
917+
{
918+
$dsn = 'mysql://dfs:dfs@localhost:3306/dfs';
919+
$parts = parse_url($dsn);
920+
921+
$relationship = [
922+
'dfs_database' => [
923+
[
924+
'host' => $parts['host'],
925+
'scheme' => $parts['scheme'],
926+
'username' => $parts['user'],
927+
'password' => $parts['pass'],
928+
'port' => $parts['port'],
929+
'path' => ltrim($parts['path'], '/'),
930+
'query' => [
931+
'is_master' => true,
932+
],
933+
],
934+
],
935+
];
936+
937+
$_SERVER['PLATFORM_RELATIONSHIPS'] = base64_encode(json_encode($relationship, JSON_THROW_ON_ERROR));
938+
$_SERVER['PLATFORMSH_DFS_NFS_PATH'] = '/';
939+
$_SERVER['PLATFORM_ROUTES'] = base64_encode(json_encode([], JSON_THROW_ON_ERROR));
940+
$_SERVER['PLATFORM_PROJECT_ENTROPY'] = '';
941+
942+
$this->container->setParameter('database_charset', 'utf8mb4');
943+
$this->container->setParameter('database_collation', 'utf8mb4_general_ci');
944+
$this->container->setParameter('kernel.project_dir', __DIR__ . '/../Resources');
945+
$this->load();
946+
947+
$this->assertContainerBuilderHasParameter('dfs_database_url');
948+
self::assertEquals($dsn, $this->container->getParameter('dfs_database_url'));
949+
950+
unset(
951+
$_SERVER['PLATFORM_RELATIONSHIPS'],
952+
$_SERVER['PLATFORMSH_DFS_NFS_PATH'],
953+
$_SERVER['PLATFORM_ROUTES'],
954+
$_SERVER['PLATFORM_PROJECT_ENTROPY']
955+
);
956+
}
957+
913958
/**
914959
* Prepare Core Container for compilation by mocking required parameters and compile it.
915960
*/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# dummy file for \Ibexa\Tests\Bundle\Core\DependencyInjection\IbexaCoreExtensionTest::testConfigurePlatformShDFS

0 commit comments

Comments
 (0)