Installing WordHat¶
Requirements¶
WordHat requires PHP (version 7.2+), Composer, and a WordPress site to test (version 4.8+).
We recommend using WP-CLI1 (version 2.1.0+).
Installation¶
- Create a folder for your tests. From a terminal:
mkdir project cd project
- Tell Composer to download WordHat:
composer require --dev paulgibbs/behat-wordpress-extension behat/mink-goutte-driver dmore/behat-chrome-extension
- Copy WordHat's sample configuration file into your
project
folder and rename it:cp vendor/paulgibbs/behat-wordpress-extension/behat.yml.dist behat.yml
Edit your
behat.yml
and:- Update the
base_url
setting with the URL of the website that you intend to test. - Update the
path
setting with either the relative or absolute path to your WordPress' files. - Update the
users
section, and specify a username and password of an administrator user account in your WordPress. - If your WordPress is installed in a subdirectory, consult the FAQ for information about the
site_url
setting.
- Update the
- Initialise Behat:
vendor/bin/behat --init
What does this do?
This creates a
features/
folder for your Features (tests), and a new Context class. These will come in handy later! - To confirm that everything is set up correctly, run:
If it worked, you will see a list of text that looks a little like the following (but much longer):vendor/bin/behat --definitions i
Given I am an anonymous user Given I am not logged in Given I am logged in as a user with the :role role(s) Given I am logged in as :name …
Next steps¶
Now that you have WordHat set up, we recommend reading our introduction to Behat to help you learn the basics before you start writing tests for your site.