Projet

Général

Profil

Révision c22e192e

Ajouté par Assos Assos il y a plus de 9 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/rules/tests/rules.test
2099 2099
    }
2100 2100
  }
2101 2101
}
2102

  
2103
/**
2104
 * Test early bootstrap Rules invocation.
2105
 */
2106
class RulesInvocationEnabledTestCase extends DrupalWebTestCase {
2107

  
2108
  /**
2109
   * {@inheritdoc}
2110
   */
2111
  public static function getInfo() {
2112
    return array(
2113
      'name' => 'Rules invocation enabled',
2114
      'description' => 'Tests that Rules events are enabled during menu item loads.',
2115
      'group' => 'Rules',
2116
    );
2117
  }
2118

  
2119
  /**
2120
   * {@inheritdoc}
2121
   */
2122
  public function setUp() {
2123
    parent::setUp('dblog', 'rules', 'rules_test', 'rules_test_invocation');
2124
  }
2125

  
2126
  /**
2127
   * Tests that a Rules event is triggered on node menu item loading.
2128
   *
2129
   * @see rules_test_invocation_node_load()
2130
   */
2131
  public function testInvocationOnNodeMenuLoading() {
2132
    // Create a test node.
2133
    $node = $this->drupalCreateNode(array('title' => 'Test'));
2134
    // Enable Rules logging on the INFO level so that entries are written to
2135
    // dblog.
2136
    variable_set('rules_log_errors', RulesLog::INFO);
2137
    // Create an empty rule that will fire in our node load hook.
2138
    $rule = rules_reaction_rule();
2139
    $rule->event('rules_test_event');
2140
    $rule->save('test_rule');
2141

  
2142
    // Visit the node page which should trigger the load hook.
2143
    $this->drupalGet('node/' . $node->nid);
2144
    $result = db_query("SELECT * FROM {watchdog} WHERE type = 'rules' AND message = 'Reacting on event %label.'")->fetch();
2145
    $this->assertFalse(empty($result), 'Rules event was triggered and logged.');
2146
  }
2147

  
2148
}

Formats disponibles : Unified diff