mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-22 09:01:01 +00:00
Skip database reset on partial test run
This commit is contained in:
parent
db5aa62509
commit
e2b8ff3dc0
3 changed files with 65 additions and 28 deletions
|
@ -200,7 +200,10 @@
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Tests\\": "tests/"
|
"Tests\\": "tests/"
|
||||||
}
|
},
|
||||||
|
"files": [
|
||||||
|
"tests/functions.php"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"allow-plugins": {
|
"allow-plugins": {
|
||||||
|
|
|
@ -7,35 +7,37 @@ require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
(new Filesystem())->remove(__DIR__ . '/../var/cache/test');
|
(new Filesystem())->remove(__DIR__ . '/../var/cache/test');
|
||||||
|
|
||||||
(new Process([
|
if (!isPartialRun()) {
|
||||||
'php',
|
(new Process([
|
||||||
__DIR__ . '/../bin/console',
|
'php',
|
||||||
'doctrine:database:drop',
|
__DIR__ . '/../bin/console',
|
||||||
'--force',
|
'doctrine:database:drop',
|
||||||
'--env=test',
|
'--force',
|
||||||
]))->run(function ($type, $buffer) {
|
'--env=test',
|
||||||
echo $buffer;
|
]))->run(function ($type, $buffer) {
|
||||||
});
|
echo $buffer;
|
||||||
|
});
|
||||||
|
|
||||||
(new Process([
|
(new Process([
|
||||||
'php',
|
'php',
|
||||||
__DIR__ . '/../bin/console',
|
__DIR__ . '/../bin/console',
|
||||||
'doctrine:database:create',
|
'doctrine:database:create',
|
||||||
'--env=test',
|
'--env=test',
|
||||||
]))->mustRun(function ($type, $buffer) {
|
]))->mustRun(function ($type, $buffer) {
|
||||||
echo $buffer;
|
echo $buffer;
|
||||||
});
|
});
|
||||||
|
|
||||||
(new Process([
|
(new Process([
|
||||||
'php',
|
'php',
|
||||||
__DIR__ . '/../bin/console',
|
__DIR__ . '/../bin/console',
|
||||||
'doctrine:migrations:migrate',
|
'doctrine:migrations:migrate',
|
||||||
'--no-interaction',
|
'--no-interaction',
|
||||||
'--env=test',
|
'--env=test',
|
||||||
'-vv',
|
'-vv',
|
||||||
]))->mustRun(function ($type, $buffer) {
|
]))->mustRun(function ($type, $buffer) {
|
||||||
echo $buffer;
|
echo $buffer;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
(new Process([
|
(new Process([
|
||||||
'php',
|
'php',
|
||||||
|
|
32
tests/functions.php
Normal file
32
tests/functions.php
Normal 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;
|
||||||
|
}
|
Loading…
Reference in a new issue