Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion libs/doctrine-retry-bundle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ doctrine:
```
## Environment
The tests connect to MySQL through a [Toxiproxy](https://github.com/Shopify/toxiproxy) instance
(used to simulate connection failures). Both are provided by the `dev-doctrine-retry-bundle`
Docker Compose service, so the simplest way to run them is:
```bash
docker compose run --rm dev-doctrine-retry-bundle composer ci
```

The following variables are required:
```
TEST_DATABASE_URL - database connection URL (mysql://user:secret@localhost/mydb)
TEST_DATABASE_HOST - MySQL host (e.g. mysql)
TEST_DATABASE_PORT - MySQL port (e.g. 3306)
TEST_DATABASE_USER - MySQL user (e.g. root)
TEST_DATABASE_PASSWORD - MySQL password
TEST_DATABASE_DB - MySQL database name (e.g. testdatabase)
TEST_PROXY_HOST - Toxiproxy host (e.g. toxiproxy); its API is reached at http://<host>:8474
```
3 changes: 2 additions & 1 deletion libs/doctrine-retry-bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"monolog/monolog": "^3.9",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^12.1"
"phpunit/phpunit": "^12.1",
"symfony/dotenv": "^6.0|^7.0"
},
"autoload": {
"psr-4": {
Expand Down
22 changes: 21 additions & 1 deletion libs/doctrine-retry-bundle/tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,24 @@

declare(strict_types=1);

require_once __DIR__ . '/../vendor/autoload.php';
use Symfony\Component\Dotenv\Dotenv;

require __DIR__ . '/../vendor/autoload.php';

if (file_exists(dirname(__DIR__).'/.env.local')) {
(new Dotenv())->usePutenv()->bootEnv(dirname(__DIR__).'/.env.local', 'dev', []);
}

$requiredEnvs = [
'TEST_DATABASE_HOST',
'TEST_DATABASE_PORT',
'TEST_DATABASE_USER',
'TEST_DATABASE_PASSWORD',
'TEST_DATABASE_DB',
'TEST_PROXY_HOST',
];
foreach ($requiredEnvs as $env) {
if (empty(getenv($env))) {
throw new Exception(sprintf('Environment variable "%s" is empty', $env));
}
}
Loading