Merge pull request #7177 from yguedidi/skip-database-reset-on-partial-test-run

Skip database reset on partial test run
This commit is contained in:
Yassine Guedidi 2024-01-16 09:33:08 +01:00 committed by GitHub
commit cda5d2daeb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 28 deletions

View file

@ -200,7 +200,10 @@
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"files": [
"tests/functions.php"
]
},
"config": {
"allow-plugins": {

View file

@ -7,6 +7,7 @@ require __DIR__ . '/../vendor/autoload.php';
(new Filesystem())->remove(__DIR__ . '/../var/cache/test');
if (!isPartialRun()) {
(new Process([
'php',
__DIR__ . '/../bin/console',
@ -36,6 +37,7 @@ require __DIR__ . '/../vendor/autoload.php';
]))->mustRun(function ($type, $buffer) {
echo $buffer;
});
}
(new Process([
'php',

32
tests/functions.php Normal file
View file

@ -0,0 +1,32 @@
<?php
/*
* This files contains functions that are used in the tests, especially the bootstrap.php file.
*/
/**
* Returns true if the current test run is a partial run.
* A partial run is a run that only runs a subset of the tests using the --filter, --testsuite, --group or --exclude-group options.
*/
function isPartialRun(): bool
{
foreach ($_SERVER['argv'] as $arg) {
if (str_starts_with($arg, '--filter')) {
return true;
}
if (str_starts_with($arg, '--testsuite')) {
return true;
}
if (str_starts_with($arg, '--group')) {
return true;
}
if (str_starts_with($arg, '--exclude-group')) {
return true;
}
}
return false;
}