Skip to content

Initial set of functional test cases to test all reference types

James Shields requested to merge issue/access_by_ref-3343101:Testing into 9.x-3.x

This change adds automated testing functionality to the class.

I have implemented a base class type AccessByRefTestBase.php as an abstract class to standardize the tests carried out on each reference type.

There is a child class to test each reference type. It is designed to minimize the code for each reference type to ensure the same tests are carried out accross all reference types.

At present the following checks take place on each type:

  • Check that authorized user cannot update node before Access by ref is configured.
  • Check that admin user can submit the correct configuration.
  • Check that user without ABR permission can't update node.
  • Check that user with ABR permission but not authorized for node cannot edit.
  • Check that user with ABR permission and authorized for node can edit. An advantage of the above approach is that if additional tests are added in future, they will automatically apply to all reference types.

There is an additional test on on the config form. At present this only checks access to the form, but I intend to add further checks on form content later.

This change is only proposed for the 3.x branch at present. It should also work for the 2.x branch if desired.

  • I have tested with phpunit to verify all tests pass.
  • I have checked Drupal coding standards of the tests with phpcs and phpstan.

This change depends on #3345165, without which the "User Email" reference type fails.

Edited by James Shields

Merge request reports