| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: rules_test.test,v 1.1.2.8 2009/07/31 10:45:44 fago Exp $ 3 4 /** 5 * @file Rules Testing Module - File containing test cases. 6 */ 7 8 class RulesTestCase extends DrupalWebTestCase { 9 public static function getInfo() { 10 return array( 11 'name' => t('Rules engine API tests'), 12 'description' => t('Tests the rules engine API to work correctly.'), 13 'group' => t('Rules engine tests'), 14 ); 15 } 16 17 function setUp() { 18 parent::setUp(); 19 drupal_install_modules(array('rules', 'rules_test')); 20 rules_test_keep_rules_log(); 21 } 22 function tearDown() { 23 parent::tearDown(); 24 rules_test_done(); 25 } 26 27 //Test changing an argument when taken by reference and verify that the changes are kept 28 function test_1() { 29 $argument = array('property_xy' => TRUE); 30 rules_invoke_rule_set('rules_test_1', $argument); 31 $error = FALSE; 32 $log = rules_test_show_log($error); 33 $this->assertFalse($error, t('Rule was not evaluated successfully.') .' '. $log); 34 } 35 36 //Test changing an argument by action and verify that the changes are kept for later rules 37 function test_2() { 38 $argument = array('property_xy' => TRUE); 39 rules_invoke_rule_set('rules_test_2', $argument); 40 $error = FALSE; 41 $log = rules_test_show_log($error); 42 43 $this->assertFalse($error, t('Rule was not evaluated successfully.') .' '. $log); 44 } 45 46 //Test passing arguments by reference to a set 47 function test_3() { 48 $argument = array('property_xy' => TRUE); 49 rules_invoke_rule_set('rules_test_2', array('rules_test' => &$argument)); 50 $error = FALSE; 51 $log = rules_test_show_log($error); 52 53 $this->assertTrue(isset($argument['altered']) && $argument['altered'], t('Argument has not been altered correctly.')); 54 $this->assertFalse($error, t('Rule was not evaluated successfully.') .' '. $log); 55 } 56 57 //Tests argument mapping and argument loading by handler 58 function test_4() { 59 $argument = array('property_xy' => TRUE); 60 rules_invoke_rule_set('rules_test_4', $argument); 61 $error = FALSE; 62 $log = rules_test_show_log($error); 63 64 $this->assertFalse($error, t('Rule was not evaluated successfully.') .' '. $log); 65 $this->assertTrue(strpos($log, 'Loaded variable "node"') !== FALSE, t('Variable was not loaded successfully.') .' '. $log); 66 } 67 68 //Tests adding a new variable 69 function test_5() { 70 rules_invoke_rule_set('rules_test_5'); 71 $error = FALSE; 72 $log = rules_test_show_log($error); 73 $this->assertFalse($error, t('Rule was not evaluated successfully.') .' '. $log); 74 $this->assertTrue(strpos($log, 'Successfully added the new variable "test"') !== FALSE, t('Variable was not added successfully.') .' '. $log); 75 } 76 } 77 78 /** 79 * Argument handler for argument 2 of rule set 4 80 */ 81 function rules_test_4_load_data($arg1) { 82 if (isset($arg1) && $arg1['property_xy']) { 83 return array('property_xy' => TRUE, 'altered' => TRUE); 84 } 85 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |