protected function UserpointsRulesTestCase::createEventRules in User Points 7.2
Set up the rules required for the tests.
1 call to UserpointsRulesTestCase::createEventRules()
- UserpointsRulesTestCase::testEvents in userpoints_rules/
userpoints_rules.test - Test the before and after events and the setter and getter callbacks.
File
- userpoints_rules/
userpoints_rules.test, line 91 - Tests for Userpoints Services integration.
Class
- UserpointsRulesTestCase
- @file Tests for Userpoints Services integration.
Code
protected function createEventRules() {
$before_rule = '{ "rules_userpoints_transaction_before_test_rule" : {
"LABEL" : "Userpoints Transaction Before Test rule",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "userpoints_rules" ],
"ON" : [ "userpoints_event_points_awarded_before" ],
"IF" : [
{ "data_is" : {
"data" : [ "userpoints-transaction:operation" ],
"value" : "userpoints_rules_trigger_before_rule"
}
}
],
"DO" : [
{ "data_set" : { "data" : [ "userpoints-transaction:status" ], "value" : "2" } },
{ "data_set" : {
"data" : [ "userpoints-transaction:description" ],
"value" : "Transaction was declined through rules."
}
}
]
}
}';
$after_rule = '{ "rules_userpoints_transaction_after_test_rule" : {
"LABEL" : "Userpoints Transaction After Test rule",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "userpoints_rules" ],
"ON" : [ "userpoints_transaction_insert" ],
"IF" : [
{ "data_is" : {
"data" : [ "userpoints-transaction:operation" ],
"value" : "userpoints_rules_trigger_after_rule"
}
}
],
"DO" : [
{ "data_set" : { "data" : [ "userpoints-transaction:status" ], "value" : "0" } },
{ "data_set" : {
"data" : [ "userpoints-transaction:reference" ],
"value" : "Transaction was set to pending through rules."
}
}
]
}
}';
// Save the rules.
$rule = rules_import($before_rule);
$rule
->save();
$rule = rules_import($after_rule);
$rule
->save();
drupal_static_reset('rules_get_cache');
cache_clear_all('*', 'cache_rules', TRUE);
}