Skip to content

Traits for testing Drupal sites that have user content (versus unpopulated sites).

License

Notifications You must be signed in to change notification settings

jhedstrom/drupal-test-traits

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Drupal Test Traits

CircleCI project-stage-badge license-badge

Introduction

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.

Installation

composer require 'weitzman/drupal-test-traits'

Authoring Tests

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.

Running Tests

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 ..."

Available traits

  • 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.

Contributing

Contributions to the this project are welcome! Please file issues and pull requests. All pull requests are automatically tested at CircleCI.

Colophon

About

Traits for testing Drupal sites that have user content (versus unpopulated sites).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%