Security update for permissions_by_term
[yaffs-website] / vendor / drupal / drupal-extension / doc / drush.rst
1 Drush Driver
2 ============
3
4 Many tests require that a user logs into the site. With the blackbox driver,
5 all user creation and login would have to take place via the user interface,
6 which quickly becomes tedious and time consuming. You can use the Drush driver
7 to add users, reset passwords, and log in by following the steps below, again,
8 without having to write custom PHP. You can also do this with the Drupal API
9 driver. The main advantage of the Drush driver is that it can work when your
10 tests run on a different server than the site being tested.
11
12 Install Drush
13 -------------
14
15 See the `Drush project page <https://drupal.org/project/drush>`_ for
16 installation directions.
17
18 Install the Behat Drush Endpoint
19 --------------------------------
20
21 The Behat Drush Endpoint is a Drush-based service that the Drush Driver uses in order to create content on the Drupal site being tested.  See the `Behat Drush Endpoint project page <https://github.com/drush-ops/behat-drush-endpoint>`_ for instructions on how to install it with your Drupal site.
22
23 Point Drush at your Drupal site
24 -------------------------------
25
26 Drupal Alias (For local or remote sites)
27 ++++++++++++++++++++++++++++++++++++++++
28
29 You'll need ssh-key access to a remote server to use Drush. If Drush and Drush
30 aliases are new to you, see the `Drush site <http://drush.ws/help>`_ for
31 `detailed examples <http://drush.ws/examples/example.aliases.drushrc.php>`_
32
33 The alias for our example looks like:
34
35 .. literalinclude:: _static/snippets/aliases.drushrc.php
36    :language: php
37    :linenos:
38
39 Path to Drupal (local sites only)
40 +++++++++++++++++++++++++++++++++
41
42 If you'll only be running drush commands to access a site on the same machine,
43 you can specify the path to your Drupal root:
44
45 .. code-block:: yaml
46    :linenos:
47
48     Drupal\DrupalExtension:
49       blackbox: ~
50     drush:
51       root: /my/path/to/drupal
52
53
54 Enable the Drush driver
55 -----------------------
56
57 In the behat.yml file:
58
59 .. literalinclude:: _static/snippets/behat-drush.yml
60    :language: yaml
61    :linenos:
62    :emphasize-lines: 15-17
63
64 .. note:: Line 15 isn't strictly necessary for the Drush driver, which is the
65           default for the API.
66
67 Calling the Drush driver
68 ------------------------
69
70 Untagged tests use the blackbox driver. To invoke the Drush driver, tag the
71 scenario with @api
72
73 .. literalinclude:: _static/snippets/apitag.feature
74    :language: gherkin
75    :linenos:
76    :emphasize-lines: 11
77
78 If you try to run a test without that tag, it will fail.
79
80 Example:
81 ++++++++
82
83 .. literalinclude:: _static/snippets/apitag.output
84    :language: gherkin
85    :linenos:
86    :emphasize-lines: 10-12
87    :lines: 1-24
88
89 The Drush driver gives you access to all the blackbox steps, plus those used in
90 each of the following examples:
91
92 .. literalinclude:: _static/snippets/drush.feature
93    :language: gherkin
94    :linenos:
95
96 If the Behat Drush Endpoint is installed on the Drupal site being tested, then you will also have access to all of the examples shown for the Drupal API driver.