-
Notifications
You must be signed in to change notification settings - Fork 13
Tests
A test suite exists under the tests
folder and comprises Unit and Functional tests.
Note tests have been developed and tested using the most recent version of stable Drupal core dev at the time: "drupal/core-dev": "9.1.7"
.
Refer to instructions on Running PHPUnit tests from the official Drupal documentation.
All dvf tests belong to the group dvf
so you can run all tests locally using something like vendor/bin/phpunit --group dvf
.
Alternatively, you can alter your phpunit.xml
by adding a custom dvf
testsuite covering this module folder only
and run something like vendor/bin/phpunit --testsuite=dvf
.
To limit tests to a unique test file run something like vendor/bin/phpunit --testsuite=dvf --filter=DvfFieldBasicConfigTest
where DvfFieldBasicConfigTest
is the test file to run all tests from.
To limit tests to a unique function run something like vendor/bin/phpunit --testsuite=dvf --filter=testAddFieldVisualisationFile
where testAddFieldVisualisationFile
is the test function run.
-
To make sure that tests will run fine on Drupal.org, you can run them on local like the Drupal testbot. Refer to Drupal documentation.
-
Note that you will need a local Drupal instance setup with the Simpletest module enabled.
For >= Drupal 8 versions, you can run these without an instance by specifying an sql lite connection in argument. See: Running tests without an installed Drupal site (D8) -
Run tests against the entire module group (
dvf
) with the following commandphp ./core/scripts/run-tests.sh --verbose --url http://yourlocalurl dvf
, from the route of your project. Note that the above example specifies a--url
flag required for functional tests (relying on Guzzle) and a--verbose
flag to provide more info on debugging.
Add a new test file to either the Functional
or Unit
folder.
Any functional test to validate field plugin configuration (source, style, visualisation options,...) should extend tests/src/Functional/DvfFieldTestBase
that provides:
- A working test environment setup with all required modules enabled and admin user with relevant permissions
- Useful traits to assist with test development.
- Improve
DvfFieldBasicConfigTest
by testing more dvf_url field and all built-in sources. - Provide framework to easily implement specific config tests, particularly visualisation options.
DvfFieldBasicConfigTest
should be used for inspiration and abstracted. - Test raw (serialised) field configuration setup on nodes, to ensure backward compatibility when updating module.
- Data file parsing, ideally Unit tests
- Js tests
- Kernel tests?