Skip to content

Commit 532c9ae

Browse files
committed
Added sample phpunit.xml file for use on DDEV.
1 parent aea162a commit 532c9ae

File tree

2 files changed

+125
-2
lines changed

2 files changed

+125
-2
lines changed

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,31 @@ The following are required to run tests.
8787
The simplest way to run tests with this setup is to put the phpunit.xml file in
8888
the project root and then run tests from there:
8989

90+
```
9091
$ vendor/bin/phpunit web/core/PATH-TO-TEST-FILE/TestFile.php
92+
```
93+
94+
##### On DDEV
9195

92-
To set this up, copy Drupal core's sample phpunit.xml file to the project root:
96+
1. Copy the `phpunit-ddev.xml` file that this template provides and rename it to
97+
`phpunit.xml`:
98+
99+
```
100+
$ cp phpunit-ddev.xml phpunit.xml
101+
```
93102

103+
2. Change the BROWSERTEST_OUTPUT_BASE_URL value to the host URL of the project.
104+
105+
##### On other platforms
106+
107+
1. Copy Drupal core's sample `phpunit.xml.dist`` file to the project root and
108+
rename it to `phpunit.xml`:
109+
110+
```
94111
$ cp web/core/phpunit.xml.dist phpunit.xml
112+
```
95113

96-
Then change the `bootstrap` attribute so the path is correct:
114+
2. Change the `bootstrap` attribute so the path is correct:
97115

98116
```
99117
<phpunit bootstrap="web/core/tests/bootstrap.php"

phpunit-ddev.xml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!-- For how to customize PHPUnit configuration, see core/tests/README.md. -->
4+
<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
5+
<!-- PHPUnit expects functional tests to be run with either a privileged user
6+
or your current system user. See core/tests/README.md and
7+
https://www.drupal.org/node/2116263 for details.
8+
-->
9+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
bootstrap="web/core/tests/bootstrap.php" colors="true"
11+
beStrictAboutTestsThatDoNotTestAnything="true"
12+
beStrictAboutOutputDuringTests="true"
13+
beStrictAboutChangesToGlobalState="true"
14+
failOnWarning="true"
15+
printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter"
16+
cacheResult="false"
17+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
18+
<php>
19+
<!-- Set error reporting to E_ALL. -->
20+
<ini name="error_reporting" value="32767"/>
21+
<!-- Do not limit the amount of memory tests take to run. -->
22+
<ini name="memory_limit" value="-1"/>
23+
<!-- Example SIMPLETEST_BASE_URL value: http://localhost -->
24+
<env name="SIMPLETEST_BASE_URL" value="http://localhost/"/>
25+
<!-- Example SIMPLETEST_DB value: mysql://username:password@localhost/databasename#table_prefix -->
26+
<env name="SIMPLETEST_DB" value="mysql://db:db@db/db"/>
27+
<!-- Example BROWSERTEST_OUTPUT_DIRECTORY value: /path/to/webroot/sites/simpletest/browser_output -->
28+
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value="/var/www/html/web/sites/simpletest/browser_output"/>
29+
<!-- By default, browser tests will output links that use the base URL set
30+
in SIMPLETEST_BASE_URL. However, if your SIMPLETEST_BASE_URL is an internal
31+
path (such as may be the case in a virtual or Docker-based environment),
32+
you can set the base URL used in the browser test output links to something
33+
reachable from your host machine here. This will allow you to follow them
34+
directly and view the output. -->
35+
<env name="BROWSERTEST_OUTPUT_BASE_URL" value="https://PROJECT_NAME.ddev.site/"/>
36+
37+
<!-- Deprecation testing is managed through Symfony's PHPUnit Bridge.
38+
The environment variable SYMFONY_DEPRECATIONS_HELPER is used to configure
39+
the behaviour of the deprecation tests.
40+
See https://symfony.com/doc/current/components/phpunit_bridge.html#configuration
41+
Drupal core's testing framework is setting this variable to its defaults.
42+
Projects with their own requirements need to manage this variable
43+
explicitly.
44+
-->
45+
<!-- To disable deprecation testing completely uncomment the next line. -->
46+
<!-- <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/> -->
47+
<!-- Deprecation errors can be selectively ignored by specifying a file of
48+
regular expression patterns for exclusion.
49+
See https://symfony.com/doc/current/components/phpunit_bridge.html#ignoring-deprecations
50+
Uncomment the line below to specify a custom deprecations ignore file.
51+
NOTE: it may be required to specify the full path to the file to run tests
52+
correctly.
53+
-->
54+
<!-- <env name="SYMFONY_DEPRECATIONS_HELPER" value="ignoreFile=.deprecation-ignore.txt"/> -->
55+
56+
<!-- Example for changing the driver class for mink tests MINK_DRIVER_CLASS value: 'Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver' -->
57+
<env name="MINK_DRIVER_CLASS" value=''/>
58+
<!-- Example for changing the driver args to mink tests MINK_DRIVER_ARGS value: '["http://127.0.0.1:8510"]' -->
59+
<env name="MINK_DRIVER_ARGS" value=''/>
60+
<!-- Example for changing the driver args to webdriver tests MINK_DRIVER_ARGS_WEBDRIVER value: '["chrome", { "chromeOptions": { "w3c": false } }, "http://localhost:4444/wd/hub"]' For using the Firefox browser, replace "chrome" with "firefox" -->
61+
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value=''/>
62+
</php>
63+
<testsuites>
64+
<testsuite name="unit">
65+
<file>./tests/TestSuites/UnitTestSuite.php</file>
66+
</testsuite>
67+
<testsuite name="kernel">
68+
<file>./tests/TestSuites/KernelTestSuite.php</file>
69+
</testsuite>
70+
<testsuite name="functional">
71+
<file>./tests/TestSuites/FunctionalTestSuite.php</file>
72+
</testsuite>
73+
<testsuite name="functional-javascript">
74+
<file>./tests/TestSuites/FunctionalJavascriptTestSuite.php</file>
75+
</testsuite>
76+
<testsuite name="build">
77+
<file>./tests/TestSuites/BuildTestSuite.php</file>
78+
</testsuite>
79+
</testsuites>
80+
<listeners>
81+
<listener class="\Drupal\Tests\Listeners\DrupalListener">
82+
</listener>
83+
</listeners>
84+
<!-- Settings for coverage reports. -->
85+
<coverage>
86+
<include>
87+
<directory>./includes</directory>
88+
<directory>./lib</directory>
89+
<directory>./modules</directory>
90+
<directory>../modules</directory>
91+
<directory>../sites</directory>
92+
</include>
93+
<exclude>
94+
<directory>./modules/*/src/Tests</directory>
95+
<directory>./modules/*/tests</directory>
96+
<directory>../modules/*/src/Tests</directory>
97+
<directory>../modules/*/tests</directory>
98+
<directory>../modules/*/*/src/Tests</directory>
99+
<directory>../modules/*/*/tests</directory>
100+
<directory suffix=".api.php">./lib/**</directory>
101+
<directory suffix=".api.php">./modules/**</directory>
102+
<directory suffix=".api.php">../modules/**</directory>
103+
</exclude>
104+
</coverage>
105+
</phpunit>

0 commit comments

Comments
 (0)