File tree Expand file tree Collapse file tree 4 files changed +43
-41
lines changed Expand file tree Collapse file tree 4 files changed +43
-41
lines changed Original file line number Diff line number Diff line change 129
129
* :doc:` /cookbook/testing/insulating_clients`
130
130
* :doc:` /cookbook/testing/profiling`
131
131
* :doc:` /cookbook/testing/doctrine`
132
+ * :doc:` /cookbook/testing/bootstrap`
132
133
133
134
* :doc:` /cookbook/validation/index`
134
135
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ How to customize the Bootstrap Process before running Tests
2
+ ===========================================================
3
+
4
+ Sometimes when running tests, you need to do additional bootstrap work before
5
+ running those tests. For example, if you're running a functional test and
6
+ have introduced a new translation resource, then you will need to clear your
7
+ cache before running those tests. This cookbook covers how to do that.
8
+
9
+ First, add the following file::
10
+
11
+ // app/tests.bootstrap.php
12
+ if (isset($_ENV['BOOTSTRAP_CLEAR_CACHE_ENV'])) {
13
+ passthru(sprintf(
14
+ 'php "%s/console" cache:clear --env=%s --no-warmup',
15
+ __DIR__,
16
+ $_ENV['BOOTSTRAP_CLEAR_CACHE_ENV']
17
+ ));
18
+ }
19
+
20
+ require __DIR__.'/bootstrap.php.cache';
21
+
22
+ Replace the test bootstrap file ``bootstrap.php.cache `` in ``app/phpunit.xml.dist ``
23
+ with ``tests.bootstrap.php ``:
24
+
25
+ .. code-block :: xml
26
+
27
+ <!-- app/phpunit.xml.dist -->
28
+ bootstrap = "tests.bootstrap.php"
29
+
30
+ Now, you can define in your ``phpunit.xml.dist `` file which environment you want the
31
+ cache to be cleared:
32
+
33
+ .. code-block :: xml
34
+
35
+ <!-- app/phpunit.xml.dist -->
36
+ <php >
37
+ <env name =" BOOTSTRAP_CLEAR_CACHE_ENV" value =" test" />
38
+ </php >
39
+
40
+ This now becomes an environment variable (i.e. ``$_ENV ``) that's available
41
+ in the custom bootstrap file (``tests.bootstrap.php ``).
Original file line number Diff line number Diff line change 8
8
insulating_clients
9
9
profiling
10
10
doctrine
11
+ bootstrap
You can’t perform that action at this time.
0 commit comments