From cf37e9033c7af57ed3ad422d5b9e8958202a60ad Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Fri, 2 Sep 2016 17:07:07 +0100 Subject: [PATCH] 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 --- core/phpunit.xml.dist | 18 +++++++++++------- core/tests/README.md | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/core/phpunit.xml.dist b/core/phpunit.xml.dist index 951bd55d44b9..9658f2ce04e5 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 dfd1154a753c..b3ed5a07e36d 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 +``` -- GitLab