Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
Thomas Hery edited this page Jun 28, 2021 · 2 revisions

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

How to run

On local, "the classic way"

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.

Run a specific test file

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.

Run a specific function

To limit tests to a unique function run something like vendor/bin/phpunit --testsuite=dvf --filter=testAddFieldVisualisationFile where testAddFieldVisualisationFile is the test function run.

On local, "The Way The Testbot Does It"

  • 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 command php ./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.

How to extend

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.

Roadmap

Short term

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

Longer term

  • Data file parsing, ideally Unit tests
  • Js tests
  • Kernel tests?