get_events() public méthode

return a list of all the actions, tags and args
public get_events ( )
 public function test_execute()
 {
     $mock = new MockAction();
     $random = md5(rand());
     add_action($random, array($mock, 'action'));
     $action = new ActionScheduler_Action($random, array($random));
     $action->execute();
     remove_action($random, array($mock, 'action'));
     $this->assertEquals(1, $mock->get_call_count());
     $events = $mock->get_events();
     $event = reset($events);
     $this->assertEquals($random, reset($event['args']));
 }
 function test_action_priority()
 {
     $a = new MockAction();
     $tag = rand_str();
     add_action($tag, array(&$a, 'action'), 10);
     add_action($tag, array(&$a, 'action2'), 9);
     do_action($tag);
     // two events, one per action
     $this->assertEquals(2, $a->get_call_count());
     $expected = array(array('action' => 'action2', 'tag' => $tag, 'args' => array('')), array('action' => 'action', 'tag' => $tag, 'args' => array('')));
     $this->assertEquals($expected, $a->get_events());
 }
Exemple #3
0
 function test_filter_priority()
 {
     $a = new MockAction();
     $tag = rand_str();
     $val = rand_str();
     // make two filters with different priorities
     add_filter($tag, array($a, 'filter'), 10);
     add_filter($tag, array($a, 'filter2'), 9);
     $this->assertEquals($val, apply_filters($tag, $val));
     // there should be two events, one per filter
     $this->assertEquals(2, $a->get_call_count());
     $expected = array(array('filter' => 'filter2', 'tag' => $tag, 'args' => array($val)), array('filter' => 'filter', 'tag' => $tag, 'args' => array($val)));
     $this->assertEquals($expected, $a->get_events());
 }
 /**
  * @ticket 30380
  */
 function test_nonexistent_key_old_timeout()
 {
     // Create a transient
     $key = 'test_transient';
     set_transient($key, 'test', 60 * 10);
     $this->assertEquals('test', get_transient($key));
     // Make sure the timeout option returns false
     $timeout = '_transient_timeout_' . $key;
     $transient_option = '_transient_' . $key;
     add_filter('option_' . $timeout, '__return_zero');
     // Mock an action for tracking action calls
     $a = new MockAction();
     // Add some actions to make sure options are deleted
     add_action('delete_option', array($a, 'action'));
     // Act
     get_transient($key);
     // Make sure delete option was called for both the transient and the timeout
     $this->assertEquals(2, $a->get_call_count());
     $expected = array(array('action' => 'action', 'tag' => 'delete_option', 'args' => array($transient_option)), array('action' => 'action', 'tag' => 'delete_option', 'args' => array($timeout)));
     $this->assertEquals($expected, $a->get_events());
 }
 /**
  * @ticket 30380
  */
 function test_nonexistent_key_old_timeout()
 {
     if (is_multisite()) {
         $this->markTestSkipped('Not testable in MS: wpmu_create_blog() defines WP_INSTALLING.');
     }
     if (wp_using_ext_object_cache()) {
         $this->markTestSkipped('Not testable with an external object cache.');
     }
     // Create a transient
     $key = 'test_transient';
     set_transient($key, 'test', 60 * 10);
     $this->assertEquals('test', get_transient($key));
     // Make sure the timeout option returns false
     $timeout = '_transient_timeout_' . $key;
     $transient_option = '_transient_' . $key;
     add_filter('option_' . $timeout, '__return_zero');
     // Mock an action for tracking action calls
     $a = new MockAction();
     // Add some actions to make sure options are deleted
     add_action('delete_option', array($a, 'action'));
     // Act
     get_transient($key);
     // Make sure delete option was called for both the transient and the timeout
     $this->assertEquals(2, $a->get_call_count());
     $expected = array(array('action' => 'action', 'tag' => 'delete_option', 'args' => array($transient_option)), array('action' => 'action', 'tag' => 'delete_option', 'args' => array($timeout)));
     $this->assertEquals($expected, $a->get_events());
 }