Skip to content

Commit

Permalink
Merge pull request #12 from asilgalis/database_url_port_fix
Browse files Browse the repository at this point in the history
Do not ignore port defined in the database url
  • Loading branch information
gedasli authored Jun 27, 2024
2 parents 0a49561 + 581cf1f commit 28b5348
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Services/DatabaseChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ private function resolveConfigFromUrl(string $url): array
'password' => $details['pass'] ?? '',
'database' => substr($details['path'] ?? '', $additionalPathChars),
'host' => $details['host'] ?? '',
'port' => $details['port'] ?? '',
];

if (empty($result['database']) && !empty($result['host']) && $result['driver'] === 'sqlite') {
Expand Down
15 changes: 14 additions & 1 deletion tests/Unit/Services/DatabaseCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,19 @@ public function getTestCheckStatusCases(): array
'expectedResult' => DatabaseChecker::STATUS_OK,
];

$cases['custom_mysql_url_port'] = [
'arguments' => [
'database.mysql_custom',
'mysql://user3:[email protected]:5306/testdb3',
],
'expectedPdoArgs' => [
'mysql:host=127.0.0.3;port=5306;dbname=testdb3',
'user3',
'pass3',
],
'expectedResult' => DatabaseChecker::STATUS_OK,
];

$cases['doctrine_mysql_parameters'] = [
'arguments' => [
'database.mysql_doctrine',
Expand Down Expand Up @@ -266,7 +279,7 @@ public function getTestCheckStatusCases(): array
],
'expectedResult' => DatabaseChecker::STATUS_OK,
'env' => [
'DATABASE_URL=mysql://user1:pass1@localhost/test_sf_db',
'DATABASE_URL=mysql://user1:pass1@localhost:3306/test_sf_db',
],
];

Expand Down

0 comments on commit 28b5348

Please sign in to comment.