summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2016-09-02 17:07:07 +0100
committerAlex Pott2016-09-02 17:07:18 +0100
commitdbcfdad78733dff584362131bb890b04206ed75d (patch)
treeca5d279927f062bba894c532fcdf756021fdb00c
parentecb1f7acc2dfab679b1473b3065d431fc6654095 (diff)
Issue #2760905 by anavarre, claudiu.cristea, amitaibu, dawehner: The documentation should be more explicit about PHPUnit requesting the webserver user to perform all functional tests
(cherry picked from commit cf37e9033c7af57ed3ad422d5b9e8958202a60ad)
-rw-r--r--core/phpunit.xml.dist18
-rw-r--r--core/tests/README.md33
2 files changed, 44 insertions, 7 deletions
diff --git a/core/phpunit.xml.dist b/core/phpunit.xml.dist
index 951bd55..9658f2c 100644
--- a/core/phpunit.xml.dist
+++ b/core/phpunit.xml.dist
@@ -1,19 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
-<!-- TODO set printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter" once
- https://youtrack.jetbrains.com/issue/WI-24808 is resolved. Drupal provides a
- result printer that links to the html output results for functional tests.
- Unfortunately, this breaks the output of PHPStorm's PHPUnit runner. However, if
- using the command line you can add
- - -printer="\Drupal\Tests\Listeners\HtmlOutputPrinter" to use it (note there
- should be no spaces between the hyphens).
+<!-- PHPUnit expects functional tests to be run with either a privileged user
+ or your current system user. See core/tests/README.md and
+ https://www.drupal.org/node/2116263 for details.
-->
<phpunit bootstrap="tests/bootstrap.php" colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
checkForUnintentionallyCoveredCode="false">
+<!-- TODO set printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter" once
+ https://youtrack.jetbrains.com/issue/WI-24808 is resolved. Drupal provides a
+ result printer that links to the html output results for functional tests.
+ Unfortunately, this breaks the output of PHPStorm's PHPUnit runner. However, if
+ using the command line you can add
+ - -printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter" to use it (note
+ there should be no spaces between the hyphens).
+-->
<php>
<!-- Set error reporting to E_ALL. -->
<ini name="error_reporting" value="32767"/>
diff --git a/core/tests/README.md b/core/tests/README.md
index dfd1154..b3ed5a0 100644
--- a/core/tests/README.md
+++ b/core/tests/README.md
@@ -13,3 +13,36 @@
./vendor/bin/phpunit -c core --testsuite functional
./vendor/bin/phpunit -c core --testsuite functional-javascript
```
+
+Note: functional tests have to be invoked with a user in the same group as the
+web server user. You can either configure Apache (or nginx) to run as your own
+system user or run tests as a privileged user instead.
+
+To develop locally, a straigtforward - but also less secure - approach is to run
+tests as your own system user. To achieve that, change the default Apache user
+to run as your system user. Typically, you'd need to modify
+`/etc/apache2/envvars` on Linux or `/etc/apache2/httpd.conf` on Mac.
+
+Example for Linux:
+
+```
+export APACHE_RUN_USER=<your-user>
+export APACHE_RUN_GROUP=<your-group>
+```
+
+Example for Mac:
+
+```
+User <your-user>
+Group <your-group>
+```
+
+If the default user is e.g. `www-data`, the above functional tests will have to
+be invoked with sudo instead:
+
+```
+export SIMPLETEST_DB='mysql://root@localhost/dev_d8'
+export SIMPLETEST_BASE_URL='http://d8.dev'
+sudo -u www-data ./vendor/bin/phpunit -c core --testsuite functional
+sudo -u www-data ./vendor/bin/phpunit -c core --testsuite functional-javascript
+```