rules_test.test in Rules 6
Rules Testing Module - File containing test cases.
File
rules_test/rules_test.test
View source
<?php
class RulesTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => t('Rules engine API tests'),
'description' => t('Tests the rules engine API to work correctly.'),
'group' => t('Rules engine tests'),
);
}
function setUp() {
parent::setUp();
drupal_install_modules(array(
'rules',
'rules_test',
));
rules_test_keep_rules_log();
}
function tearDown() {
parent::tearDown();
rules_test_done();
}
function test_1() {
$argument = array(
'property_xy' => TRUE,
);
rules_invoke_rule_set('rules_test_1', $argument);
$error = FALSE;
$log = rules_test_show_log($error);
$this
->assertFalse($error, t('Rule was not evaluated successfully.') . ' ' . $log);
}
function test_2() {
$argument = array(
'property_xy' => TRUE,
);
rules_invoke_rule_set('rules_test_2', $argument);
$error = FALSE;
$log = rules_test_show_log($error);
$this
->assertFalse($error, t('Rule was not evaluated successfully.') . ' ' . $log);
}
function test_3() {
$argument = array(
'property_xy' => TRUE,
);
rules_invoke_rule_set('rules_test_2', array(
'rules_test' => &$argument,
));
$error = FALSE;
$log = rules_test_show_log($error);
$this
->assertTrue(isset($argument['altered']) && $argument['altered'], t('Argument has not been altered correctly.'));
$this
->assertFalse($error, t('Rule was not evaluated successfully.') . ' ' . $log);
}
function test_4() {
$argument = array(
'property_xy' => TRUE,
);
rules_invoke_rule_set('rules_test_4', $argument);
$error = FALSE;
$log = rules_test_show_log($error);
$this
->assertFalse($error, t('Rule was not evaluated successfully.') . ' ' . $log);
$this
->assertTrue(strpos($log, 'Loaded variable "node"') !== FALSE, t('Variable was not loaded successfully.') . ' ' . $log);
}
function test_5() {
rules_invoke_rule_set('rules_test_5');
$error = FALSE;
$log = rules_test_show_log($error);
$this
->assertFalse($error, t('Rule was not evaluated successfully.') . ' ' . $log);
$this
->assertTrue(strpos($log, 'Successfully added the new variable "test"') !== FALSE, t('Variable was not added successfully.') . ' ' . $log);
}
}
function rules_test_4_load_data($arg1) {
if (isset($arg1) && $arg1['property_xy']) {
return array(
'property_xy' => TRUE,
'altered' => TRUE,
);
}
}
Functions
Classes
Name |
Description |
RulesTestCase |
@file Rules Testing Module - File containing test cases. |