I'm creating this issue from #2786079: Relation Rules tests are not passing with newest versions of contrib dependencies and/or new test system..

Test that enables rules_admin and clicks "Add action" link triggers an exception. This is old test code, so I think an update in rules or entity api must have caused this.

I've copy pasted the failing test code from Relation to Rules to get Relation out of the picture. The error is still the same, Entity API gives error Trying to get property of non-object in entity_metadata_taxonomy_access().

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikran created an issue. See original summary.

mikran’s picture

mikran’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: rules_admin_test_fail.patch, failed testing.

TR’s picture

Status: Needs work » Closed (works as designed)

I looked at this and experimented some. Yes, when I run your test, it fails. But I have come to the conclusion that this is not a bug in Rules, it is a bug in your test.

The primary reason for this conclusion is that it WORKS on a real website, when you perform those steps interactively. Testing is only an emulation of running a real site, and there are always problems you encounter in tests that you would never see on a real site.

But to cut to the chase, your test can be made to run by adding the 'administer taxonomy' permission to your drupalCreateUser() call. It's currently failing because somewhere the code is trying to delete a taxonomy term, and your user doesn't have permission to do that. I don't know why this is the case, but as I said it works interactively without the 'administer taxonomy' permission so my conclusion is that the failure is because of how the rules_admin module was enabled in your test.

One thing I've learned about Simpletests is that if you want to enable a module, you should do it by declaring it in the public static $modules variable. Trying to enable a module later on in testing has always caused problems with Simpletests. In fact, you do two things to try to work around this - you have recognized that module_enable() isn't sufficient, and you're doing:

    // Resets permissions, because module_enable() doesn't clear static cache.
    $this->checkPermissions(array(), TRUE);

and also

    // Clears the cache, because UI module's menu items don't exists.
    drupal_flush_all_caches();

But even those two things aren't enough.

I have to assume that the test failure is because there is still something additional that needs to be done to properly enable the rules_admin module in your test, and that this missing something is done properly when enabling rules_admin from the beginning. Frankly I'm not too interested in debugging your code, I just wanted to convince myself that this was (or was not) a bug in Rules.

Regardless, it seems to be a simple permissions problem, so I'm closing this and marking it 'works as designed'.