Skip to content

Commit a7d8d97

Browse files
committed
[#8605] Updated the article a little more, using the tests/ directory.
1 parent 5d2eb53 commit a7d8d97

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

testing/bootstrap.rst

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,47 @@ 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-
To do this, first add the following file::
9+
To do this, first add a file that executes your bootstrap work::
1010

11-
// tests.bootstrap.php
11+
// tests/bootstrap.php
1212
if (isset($_ENV['BOOTSTRAP_CLEAR_CACHE_ENV'])) {
13+
// executes the "php bin/console cache:clear" command
1314
passthru(sprintf(
14-
'php "%s/bin/console" cache:clear --env=%s --no-warmup',
15+
'php "%s/../bin/console" cache:clear --env=%s --no-warmup',
1516
__DIR__,
1617
$_ENV['BOOTSTRAP_CLEAR_CACHE_ENV']
1718
));
1819
}
1920

20-
require __DIR__ . '/vendor/autoload.php';
21+
require __DIR__.'/../vendor/autoload.php';
2122

22-
Replace the test bootstrap file ``autoload.php`` in ``phpunit.xml.dist``
23-
with ``tests.bootstrap.php``:
23+
Then, configure ``phpunit.xml.dist`` to execute this ``bootstra.php`` file
24+
before running the tests:
2425

2526
.. code-block:: xml
2627
2728
<!-- phpunit.xml.dist -->
28-
29-
<!-- ... -->
29+
<?xml version="1.0" encoding="UTF-8"?>
3030
<phpunit
31-
bootstrap = "tests.bootstrap.php"
31+
bootstrap="tests/bootstrap.php"
3232
>
33+
<!-- ... -->
34+
</phpunit>
3335
3436
Now, you can define in your ``phpunit.xml.dist`` file which environment you want the
3537
cache to be cleared:
3638

3739
.. code-block:: xml
3840
3941
<!-- phpunit.xml.dist -->
40-
<php>
41-
<env name="BOOTSTRAP_CLEAR_CACHE_ENV" value="test" />
42-
</php>
42+
<?xml version="1.0" encoding="UTF-8"?>
43+
<phpunit>
44+
<!-- ... -->
45+
46+
<php>
47+
<env name="BOOTSTRAP_CLEAR_CACHE_ENV" value="test" />
48+
</php>
49+
</phpunit>
4350
4451
This now becomes an environment variable (i.e. ``$_ENV``) that's available
4552
in the custom bootstrap file (``tests.bootstrap.php``).

0 commit comments

Comments
 (0)