Skip to content

Commit c08e8fd

Browse files
sudo-barunwouterj
authored andcommitted
Fix example code of customization of bootstrapping in test
The change is copied from Symfony 4.4.
1 parent 117ed8f commit c08e8fd

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

testing/bootstrap.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ running those tests. For example, if you're running a functional test and
66
have introduced a new translation resource, then you will need to clear your
77
cache before running those tests.
88

9-
Symfony already created the following ``tests/bootstrap.php`` file when installing
10-
the package to work with tests. If you don't have this file, create it::
9+
To do this, first add a file that executes your bootstrap work::
1110

1211
// tests/bootstrap.php
13-
use Symfony\Component\Dotenv\Dotenv;
14-
15-
require dirname(__DIR__).'/vendor/autoload.php';
16-
17-
if (file_exists(dirname(__DIR__).'/config/bootstrap.php')) {
18-
require dirname(__DIR__).'/config/bootstrap.php';
19-
} elseif (method_exists(Dotenv::class, 'bootEnv')) {
20-
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
12+
if (isset($_ENV['BOOTSTRAP_CLEAR_CACHE_ENV'])) {
13+
// executes the "php bin/console cache:clear" command
14+
passthru(sprintf(
15+
'APP_ENV=%s php "%s/../bin/console" cache:clear --no-warmup',
16+
$_ENV['BOOTSTRAP_CLEAR_CACHE_ENV'],
17+
__DIR__
18+
));
2119
}
2220

21+
require __DIR__.'/../config/bootstrap.php';
22+
2323
Then, check that your ``phpunit.xml.dist`` file runs this ``bootstrap.php`` file
2424
before running the tests:
2525

0 commit comments

Comments
 (0)