Testing complex node access logic

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
Ghostthinker's picture

Background

I try to create an automated test for my drupal 7 site to test my rather complex access logic. I am using features, git and drush and a couple of shell scripts for staging. Works great.

My site involves a node access control based on several facts. I wrote a custom module (actually a feature) to create the workflow rules (other workflow module were not fitting my needs)

  • workflow_state (custom field)
  • workflow history
  • global roles
  • organic group roles

I wrote a custom access_module to handle all the node access and it works all great - for now, for the current configuration.

The problem - configuration testing

In my opinion simple test is not the right tool to test my site (at least the access logic). I want to test if my custom code AND custtom configuration are still working together as expected. I want to test if - with the current og, roles,... configuration - my site still meets my requirements after intergration new features. I think simple test is more for testing a certain modul rather than testing your configuration.

Solutions?

I thought of writing a custom mymodule_test.module that I can activate on a testing/staging instance with the following pupose:

  • Programmatically create users, groups and nodes
  • Programmatically check via node_access if the access system works a desired.

But before I do this I wanted to ask the community: What do you think of it? How do you test your site? What tools di you use?

Comments

Have you thought about using

Yaron Tal's picture

Have you thought about using features and enabling the features in the setUp method?

I have to agree it feels wrong to use simpletest this way, but when creating tests in a custom module, created for a single project, it seems like a not so strange thing to do.

At the Moment I write drush

Ghostthinker's picture

At the Moment I write drush functions. This way I can use it with my continous integration server.

I think features is

igor.ro's picture

I think features is acceptable.
Module that creates data looks like simple setUp code that can be inheritanced.
Probably you will save time by setting features before run tests and use simpletest_clone module to just clone DB state.