More updates to stop using dev or alpha or beta versions.
[yaffs-website] / web / core / tests / README.md
1 # Running tests
2
3 ## Functional tests
4
5 * Run the functional tests:
6   ```
7   export SIMPLETEST_DB='mysql://root@localhost/dev_d8'
8   export SIMPLETEST_BASE_URL='http://d8.dev'
9   ./vendor/bin/phpunit -c core --testsuite functional
10   ```
11
12 Note: functional tests have to be invoked with a user in the same group as the
13 web server user. You can either configure Apache (or nginx) to run as your own
14 system user or run tests as a privileged user instead.
15
16 To develop locally, a straightforward - but also less secure - approach is to
17 run tests as your own system user. To achieve that, change the default Apache
18 user to run as your system user. Typically, you'd need to modify
19 `/etc/apache2/envvars` on Linux or `/etc/apache2/httpd.conf` on Mac.
20
21 Example for Linux:
22
23 ```
24 export APACHE_RUN_USER=<your-user>
25 export APACHE_RUN_GROUP=<your-group>
26 ```
27
28 Example for Mac:
29
30 ```
31 User <your-user>
32 Group <your-group>
33 ```
34
35 ## Functional javascript tests
36
37 Javascript tests use the Selenium2Driver which allows you to control a
38 big range of browsers. By default Drupal uses chromedriver to run tests.
39 For help installing and starting selenium, see http://mink.behat.org/en/latest/drivers/selenium2.html
40
41 * Make sure you have a recent version of chrome installed
42
43 * Install selenium-server-standalone and chromedriver
44
45 Example for Mac:
46
47 ```
48 brew install selenium-server-standalone
49 brew install chromedriver
50 ```
51
52 * Before running tests make sure that selenium-server is running
53 ```
54 selenium-server -port 4444
55 ```
56
57 * Set the correct driver args and run the tests:
58 ```
59 export MINK_DRIVER_ARGS_WEBDRIVER='["chrome", null, "http://localhost:4444/wd/hub"]'
60 ./vendor/bin/phpunit -c core --testsuite functional-javascript
61 ```
62
63 * It is possible to use alternate browsers if the required dependencies are
64 installed. For example to use Firefox:
65
66 ```
67 export MINK_DRIVER_ARGS_WEBDRIVER='["firefox", null, "http://localhost:4444/wd/hub"]'
68 ./vendor/bin/phpunit -c core --testsuite functional-javascript
69 ```
70
71 * To force all BrowserTestBase (including legacy JavascriptTestBase) tests to use
72 webdriver:
73
74 ```
75 export MINK_DRIVER_CLASS='Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver'
76 ./vendor/bin/phpunit -c core --testsuite functional-javascript
77 ```
78
79 ## Running legacy javascript tests
80
81 Older javascript test may use the PhantomJSDriver. To run these tests you will
82 have to install and start PhantomJS.
83
84 * Start PhantomJS:
85   ```
86   phantomjs --ssl-protocol=any --ignore-ssl-errors=true ./vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768 2>&1 >> /dev/null &
87   ```
88
89 * Then you can run the test:
90 ```
91 ./vendor/bin/phpunit -c core --testsuite functional-javascript
92 ```
93
94 ## Running tests with a different user
95
96 If the default user is e.g. `www-data`, the above functional tests will have to
97 be invoked with sudo instead:
98
99 ```
100 export SIMPLETEST_DB='mysql://root@localhost/dev_d8'
101 export SIMPLETEST_BASE_URL='http://d8.dev'
102 sudo -u www-data -E ./vendor/bin/phpunit -c core --testsuite functional
103 sudo -u www-data -E ./vendor/bin/phpunit -c core --testsuite functional-javascript
104 ```