You are here

function RelationRulesTestCase::testRelationInRulesAdmin in Relation 7

Test that relation options are available in rules admin UIs.

File

tests/relation.rules.test, line 83
Tests for Rules support.

Class

RelationRulesTestCase
Functional test of Relation's integration with Rules.

Code

function testRelationInRulesAdmin() {

  // Tests that relation properties are available in rules. So create a new
  // rule with relation action, and check that the text is available among the
  // "Data selectors" list.
  // Enables UI module for rules.
  module_enable(array(
    'rules_admin',
  ));

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

  // Creates new user.
  $user = $this
    ->drupalCreateUser(array(
    'administer rules',
  ));
  $this
    ->drupalLogin($user);

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

  // Creates rule.
  $this
    ->drupalGet('admin/config/workflow/rules/reaction/add');
  $post = array(
    'settings[label]' => 'Similar',
    'settings[name]' => 'similar',
    'event' => 'node_view',
  );
  $this
    ->drupalPost(NULL, $post, t('Save'));

  // Adds action.
  // Temporary workaround, with taxonomy module enabled this Add action click
  // link triggers:
  //   Exception Notice   Trying to get property of non-object
  //     callbacks.inc      827 entity_metadata_taxonomy_access()
  module_disable(array(
    'taxonomy',
  ));
  $this
    ->clickLink(t('Add action'));
  $post = array(
    'element_name' => 'relation_rules_load_related',
  );
  $this
    ->drupalPost(NULL, $post, t('Continue'));
  $this
    ->assertText('node:relation-directional-node-reverse:0', t('The created relation porperties\' are found.'));
}