Traits for testing Drupal sites that have user content (versus unpopulated sites).
Behat is great for facilitating conversations between business managers and developers. Those are useful conversations, but many organizations simply can't/wont converse via Gherkin. When you are on the hook for product quality and not conversations, this is a testing approach for you.
composer require 'weitzman/drupal-test-traits'
See ExampleTest.php
Add a use
statement for the desired trait to your PHPUnit test class. Since our
traits have a @before annotation, Drupal and Mink are automatically setup.
You must specify the URL to your site as an environment variable: DTT_BASE_URL=http://example.com
. Here are two ways to do that:
- Enter that line into a .env file. These files are supported by drupal-project and Docker.
- Specify an environment variable at runtime:
DTT_BASE_URL=http://127.0.0.1:8888 vendor/bin/phpunit ...
Depending on your setup, you may wish to run phpunit as the web server user su -s /bin/bash www-data -c "vendor/bin/phpunit ..."
-
DrupalSetup -- Bootstrap Drupal (and more).
Bootstraps Drupal so that its API's are available. Also offers an entity cleanup API so databases are kept relatively free of testing content. -
MinkSetup -- Create a Mink session.
Makes Mink available for browser control, and offers a few helper methods.
Contributions to the this project are welcome! Please file issues and pull requests. All pull requests are automatically tested at CircleCI.
- Author: Created by Moshe Weitzman.
- License: Licensed under the MIT license