Changeset 25 in tests for wp-testcase/test_actions.php
- Timestamp:
- 09/22/2007 11:45:08 PM (19 years ago)
- File:
-
- 1 edited
-
wp-testcase/test_actions.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-testcase/test_actions.php
r24 r25 20 20 } 21 21 22 // one tag with multiple actions 22 23 function test_multiple_actions() { 23 24 $a1 = new MockAction(); … … 48 49 $this->assertEquals(array($val), array_pop($a->get_args())); 49 50 } 51 52 function test_action_args_2() { 53 $a1 = new MockAction(); 54 $a2 = new MockAction(); 55 $tag = rand_str(); 56 $val1 = rand_str(); 57 $val2 = rand_str(); 58 59 // a1 accepts two arguments, a2 doesn't 60 add_action($tag, array(&$a1, 'action'), 10, 2); 61 add_action($tag, array(&$a2, 'action')); 62 // call the action with two arguments 63 do_action($tag, $val1, $val2); 64 65 // a1 should be called with both args 66 $this->assertEquals(1, $a1->get_call_count()); 67 $this->assertEquals(array($val1, $val2), array_pop($a1->get_args())); 68 69 // a2 should be called with one only 70 $this->assertEquals(1, $a2->get_call_count()); 71 $this->assertEquals(array($val1), array_pop($a2->get_args())); 72 } 73 74 function test_action_priority() { 75 $a = new MockAction(); 76 $tag = rand_str(); 77 78 add_action($tag, array(&$a, 'action'), 10); 79 add_action($tag, array(&$a, 'action2'), 9); 80 do_action($tag); 81 82 // two events, one per action 83 $this->assertEquals(2, $a->get_call_count()); 84 85 $expected = array ( 86 // action2 is called first because it has priority 9 87 array ( 88 'action' => 'action2', 89 'tag' => $tag, 90 'args' => array('') 91 ), 92 // action 1 is called second 93 array ( 94 'action' => 'action', 95 'tag' => $tag, 96 'args' => array('') 97 ), 98 ); 99 100 $this->assertEquals($expected, $a->get_events()); 101 } 102 50 103 } 51 104
Note:
See TracChangeset
for help on using the changeset viewer.