@@ -6,40 +6,47 @@ running those tests. For example, if you're running a functional test and
6
6
have introduced a new translation resource, then you will need to clear your
7
7
cache before running those tests.
8
8
9
- To do this, first add the following file::
9
+ To do this, first add a file that executes your bootstrap work ::
10
10
11
- // tests. bootstrap.php
11
+ // tests/ bootstrap.php
12
12
if (isset($_ENV['BOOTSTRAP_CLEAR_CACHE_ENV'])) {
13
+ // executes the "php bin/console cache:clear" command
13
14
passthru(sprintf(
14
- 'php "%s/bin/console" cache:clear --env=%s --no-warmup',
15
+ 'php "%s/../ bin/console" cache:clear --env=%s --no-warmup',
15
16
__DIR__,
16
17
$_ENV['BOOTSTRAP_CLEAR_CACHE_ENV']
17
18
));
18
19
}
19
20
20
- require __DIR__ . ' /vendor/autoload.php';
21
+ require __DIR__.'/.. /vendor/autoload.php';
21
22
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:
24
25
25
26
.. code-block :: xml
26
27
27
28
<!-- phpunit.xml.dist -->
28
-
29
- <!-- ... -->
29
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
30
30
<phpunit
31
- bootstrap = " tests. bootstrap.php"
31
+ bootstrap = " tests/ bootstrap.php"
32
32
>
33
+ <!-- ... -->
34
+ </phpunit >
33
35
34
36
Now, you can define in your ``phpunit.xml.dist `` file which environment you want the
35
37
cache to be cleared:
36
38
37
39
.. code-block :: xml
38
40
39
41
<!-- 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 >
43
50
44
51
This now becomes an environment variable (i.e. ``$_ENV ``) that's available
45
52
in the custom bootstrap file (``tests.bootstrap.php ``).
0 commit comments