From e2b8ff3dc09fb7ba39f5fcbad1fb584ab223f217 Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Fri, 12 Jan 2024 21:57:18 +0100 Subject: [PATCH] Skip database reset on partial test run --- composer.json | 5 +++- tests/bootstrap.php | 56 +++++++++++++++++++++++---------------------- tests/functions.php | 32 ++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 28 deletions(-) create mode 100644 tests/functions.php diff --git a/composer.json b/composer.json index 1c4d7743c..0d14509c0 100644 --- a/composer.json +++ b/composer.json @@ -200,7 +200,10 @@ "autoload-dev": { "psr-4": { "Tests\\": "tests/" - } + }, + "files": [ + "tests/functions.php" + ] }, "config": { "allow-plugins": { diff --git a/tests/bootstrap.php b/tests/bootstrap.php index a84eb8700..66c06715f 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -7,35 +7,37 @@ require __DIR__ . '/../vendor/autoload.php'; (new Filesystem())->remove(__DIR__ . '/../var/cache/test'); -(new Process([ - 'php', - __DIR__ . '/../bin/console', - 'doctrine:database:drop', - '--force', - '--env=test', -]))->run(function ($type, $buffer) { - echo $buffer; -}); +if (!isPartialRun()) { + (new Process([ + 'php', + __DIR__ . '/../bin/console', + 'doctrine:database:drop', + '--force', + '--env=test', + ]))->run(function ($type, $buffer) { + echo $buffer; + }); -(new Process([ - 'php', - __DIR__ . '/../bin/console', - 'doctrine:database:create', - '--env=test', -]))->mustRun(function ($type, $buffer) { - echo $buffer; -}); + (new Process([ + 'php', + __DIR__ . '/../bin/console', + 'doctrine:database:create', + '--env=test', + ]))->mustRun(function ($type, $buffer) { + echo $buffer; + }); -(new Process([ - 'php', - __DIR__ . '/../bin/console', - 'doctrine:migrations:migrate', - '--no-interaction', - '--env=test', - '-vv', -]))->mustRun(function ($type, $buffer) { - echo $buffer; -}); + (new Process([ + 'php', + __DIR__ . '/../bin/console', + 'doctrine:migrations:migrate', + '--no-interaction', + '--env=test', + '-vv', + ]))->mustRun(function ($type, $buffer) { + echo $buffer; + }); +} (new Process([ 'php', diff --git a/tests/functions.php b/tests/functions.php new file mode 100644 index 000000000..a9b8881a7 --- /dev/null +++ b/tests/functions.php @@ -0,0 +1,32 @@ +