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
```
19 changes: 11 additions & 8 deletions libs/doctrine-retry-bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@
"require": {
"php": "^8.4",
"doctrine/dbal": "^4.2",
"doctrine/doctrine-bundle": "^2.1",
"doctrine/doctrine-bundle": "^3.0",
"keboola/retry": "^0.5.0",
"symfony/dependency-injection": "^7.0|^6.4",
"symfony/http-kernel": "^7.0|^6.4"
"symfony/dependency-injection": "^8.0|^7.4",
"symfony/http-kernel": "^8.0|^7.4"
},
"require-dev": {
"ext-pdo": "*",
"ihsw/toxiproxy-php-client": "^3.0",
"keboola/coding-standard": "^15.1",
"keboola/coding-standard": "^16.0",
"monolog/monolog": "^3.9",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-doctrine": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^12.1"
"phpstan/phpstan-symfony": "^2.0",
"phpunit/phpunit": "^13.0",
"symfony/dotenv": "^8.0|^7.4"
},
"autoload": {
"psr-4": {
Expand All @@ -45,9 +48,9 @@
},
"scripts": {
"phpunit": "phpunit",
"phpstan": "phpstan analyse",
"phpcs": "phpcs -n --ignore=vendor --extensions=php .",
"phpcbf": "phpcbf -n --ignore=vendor --extensions=php .",
"phpstan": "phpstan analyse --no-progress",
"phpcs": "phpcs --extensions=php src tests",
"phpcbf": "phpcbf --extensions=php src tests",
"build": [
"@composer validate --no-check-publish --no-check-all",
"@phpcs",
Expand Down
10 changes: 0 additions & 10 deletions libs/doctrine-retry-bundle/phpstan.neon

This file was deleted.

13 changes: 13 additions & 0 deletions libs/doctrine-retry-bundle/phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
parameters:
level: max
paths:
- src
- tests

ignoreErrors:
-
identifier: missingType.iterableValue

includes:
- vendor/phpstan/phpstan-phpunit/extension.neon

16 changes: 5 additions & 11 deletions libs/doctrine-retry-bundle/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/13.0/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
cacheResultFile="/tmp/phpunit.result.cache">
<coverage processUncoveredFiles="true">
<include>
bootstrap="tests/bootstrap.php">
<source><include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</include></source>
<php>
<!-- the value is the FQCN of the application kernel -->
<env name="KERNEL_CLASS" value="App\Kernel"/>
Expand Down
3 changes: 2 additions & 1 deletion libs/doctrine-retry-bundle/src/Database/Retry/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Keboola\DoctrineRetryBundle\Database\Retry;

use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware;
use Retry\RetryProxyInterface;

Expand All @@ -28,7 +29,7 @@ public function __construct(DriverInterface $driver, RetryProxyInterface $retryP
public function connect(array $params): DriverInterface\Connection
{
/** @var DriverInterface\Connection $result */
$result = $this->retryProxy->call(fn() => parent::connect($params));
$result = $this->retryProxy->call(fn(): Connection => parent::connect($params));
return $result;
}
}
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