-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(feat): add
DB_CONNECTION
environment variable for test differe…
…nt database platform - Update GitHub actions build with new steps
- Loading branch information
Showing
12 changed files
with
131 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,58 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Ranky\MediaBundle\Infrastructure\Persistence\Dql\Mysql\MimeSubType; | ||
use Ranky\MediaBundle\Infrastructure\Persistence\Dql\Mysql\MimeType; | ||
use Ranky\MediaBundle\Infrastructure\Persistence\Dql\Mysql\Month; | ||
use Ranky\MediaBundle\Infrastructure\Persistence\Dql\Mysql\Year; | ||
use Ranky\MediaBundle\Infrastructure\Persistence\Dql\Postgresql\MimeSubType as PostgresqlMimeSubType; | ||
use Ranky\MediaBundle\Infrastructure\Persistence\Dql\Postgresql\MimeType as PostgresqlMimeType; | ||
use Ranky\MediaBundle\Infrastructure\Persistence\Dql\Postgresql\Month as PostgresqlMonth; | ||
use Ranky\MediaBundle\Infrastructure\Persistence\Dql\Postgresql\Year as PostgresqlYear; | ||
use Symfony\Config\DoctrineConfig; | ||
|
||
return static function (DoctrineConfig $doctrineConfig): void { | ||
# "TEST_TOKEN" is typically set by ParaTest | ||
$doctrineConfig->dbal() | ||
->defaultConnection('default') | ||
->connection('default') | ||
->url('%env(resolve:DATABASE_URL)%') | ||
->dbnameSuffix('_test%env(default::TEST_TOKEN)%') | ||
->logging(false) | ||
->charset('utf8') | ||
$dbal = $doctrineConfig->dbal(); | ||
$dbConnection = $_SERVER['DB_CONNECTION'] ?? 'default'; | ||
|
||
$dbalConnection = $dbal->connection('default'); | ||
$dbal->defaultConnection('default'); | ||
if ($dbConnection === 'postgres') { | ||
$dbalConnection | ||
->charset('utf8') | ||
->url(getenv('POSTGRES_DATABASE_URL')) | ||
; | ||
}else{ | ||
$dbalConnection | ||
->charset('utf8mb4') | ||
->url(getenv('MYSQL_DATABASE_URL')) | ||
; | ||
|
||
} | ||
|
||
$emDefault = $doctrineConfig->orm()->autoGenerateProxyClasses(true)->entityManager('default'); | ||
$emDefault->autoMapping(true); | ||
$emDefault | ||
->mapping('Tests') | ||
$orm = $doctrineConfig->orm(); | ||
$orm->defaultEntityManager('default')->autoGenerateProxyClasses(true); | ||
|
||
$em = $orm->entityManager('default'); | ||
$em->connection('default'); | ||
$em->autoMapping(true); | ||
$em->namingStrategy('doctrine.orm.naming_strategy.underscore'); | ||
$em->mapping('Tests') | ||
->dir('%kernel.project_dir%/src/Dummy') | ||
->prefix('Ranky\MediaBundle\Tests\Dummy') | ||
; | ||
->prefix('Ranky\MediaBundle\Tests\Dummy'); | ||
$dql = $em->dql(); | ||
|
||
if ($dbConnection === 'postgres') { | ||
$dql->stringFunction('MIME_TYPE', PostgresqlMimeType::class); | ||
$dql->stringFunction('MIME_SUBTYPE', PostgresqlMimeSubType::class); | ||
$dql->datetimeFunction('YEAR', PostgresqlYear::class); | ||
$dql->datetimeFunction('MONTH', PostgresqlMonth::class); | ||
}else{ | ||
$dql->stringFunction('MIME_TYPE', MimeType::class); | ||
$dql->stringFunction('MIME_SUBTYPE', MimeSubType::class); | ||
$dql->datetimeFunction('YEAR', Year::class); | ||
$dql->datetimeFunction('MONTH', Month::class); | ||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters