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).
composer require --dev drupal/testmode
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.
- When writing Behat tests, all test content items (nodes,
terms, users) follow specific pattern. For example, node titles start with
[TEST]
. - A machine name of a view, which needs to be tested, is added to Testmode configuration form.
- 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.
Releases in GitHub are automatically pushed to http://drupal.org/project/testmode by CI.
https://www.drupal.org/project/issues/testmode
Provided that you have PHP installed locally, you can develop an extension using the provided scripts.
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
.
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
- PHPCS config:
phpcs.xml
- PHPStan config:
phpstan.neon
- PHPMD config:
phpmd.xml
- Rector config:
rector.php
- Twig CS Fixer config:
.twig-cs-fixer.php
Run tests individually with cd build && ./vendor/bin/phpunit
(ahoy test
or make test
) to run all test for
Testmode.
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