Skip to content

💧 Drupal module used to alter existing site content and other configurations when running tests.

License

Notifications You must be signed in to change notification settings

AlexSkrypnyk/testmode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Testmode logo

Drupal module to modify existing site content and configurations while running tests.

GitHub Issues GitHub Pull Requests Test GitHub release (latest by date) LICENSE Renovate

Drupal 10 Drupal 11


This is a module to support testing, so it is not expected to be used in production (although, it adheres to Drupal coding standards and has good test coverage).

Installation

composer require --dev drupal/testmode

Use case

Running a Behat test on the site with existing content may result in false-positives because of the live content being mixed with the test content.

Example: list of 3 featured articles. When the test creates 3 articles and makes them featured, there may be existing featured articles that will confuse tests resulting in a false-positive failure.

How it works

  1. When writing Behat tests, all test content items (nodes, terms, users) follow specific pattern. For example, node titles start with [TEST] .
  2. A machine name of a view, which needs to be tested, is added to Testmode configuration form.
  3. Behat test tagged with @testmode will put the site in test mode that will filter-out all items in the view that do not fit the pattern, leaving only content items created by the test.

Maintenance / Development

Releases in GitHub are automatically pushed to http://drupal.org/project/testmode by CI.

Issues

https://www.drupal.org/project/issues/testmode

Local development

Provided that you have PHP installed locally, you can develop an extension using the provided scripts.

Build

Run the following commands to start inbuilt PHP server locally and run the same commands as in CI, plus installing a site and Testmode automatically.

./.devtools/assemble.sh
./.devtools/start.sh
./.devtools/provision.sh

or ahoy build or make build.

Code linting

Run tools individually (or ahoy lint to run all tools if Ahoy is installed or make lint) to lint your code according to the Drupal coding standards.

cd build

vendor/bin/phpcs
vendor/bin/phpstan
vendor/bin/rector --clear-cache --dry-run
vendor/bin/phpmd . text phpmd.xml
vendor/bin/twig-cs-fixer

Tests

Run tests individually with cd build && ./vendor/bin/phpunit (ahoy test or make test) to run all test for Testmode.

Browsing SQLite database

To browse the contents of created SQLite database (located at /tmp/site_testmode.sqlite), use DB Browser for SQLite.


This repository was created using the Drupal Extension Scaffold project template

About

💧 Drupal module used to alter existing site content and other configurations when running tests.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 3

  •  
  •  
  •