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