get_args() public method

return an array of args passed in calls to this action
public get_args ( )
 /**
  * Test arbitrary context actions given a context and type.
  *
  * @param  string $context The context being tested.
  * @param  string $type The subcontext being tested.
  */
 protected function _context_action_assertions($context, $type)
 {
     $a = new MockAction();
     if ($context) {
         add_action("fm_{$context}", array(&$a, 'action'));
     }
     if ($type) {
         add_action("fm_{$context}_{$type}", array(&$a, 'action'));
     }
     fm_get_context(true);
     fm_trigger_context_action();
     if ($type) {
         // only two events occurred for the hook
         $this->assertEquals(2, $a->get_call_count());
         // only our hooks were called
         $this->assertEquals(array("fm_{$context}_{$type}", "fm_{$context}"), $a->get_tags());
         // The $type should have been passed as args
         $this->assertEquals(array(array($type), array($type)), $a->get_args());
     } elseif ($context) {
         // only one event occurred for the hook
         $this->assertEquals(1, $a->get_call_count());
         // only our hook was called
         $this->assertEquals(array("fm_{$context}"), $a->get_tags());
         // null should have been passed as an arg
         $this->assertEquals(array(array(null)), $a->get_args());
     } else {
         // No event should have fired
         $this->assertEquals(0, $a->get_call_count());
     }
 }
 /**
  * @ticket 11241
  */
 function test_action_keyed_array()
 {
     $a = new MockAction();
     $tag = rand_str();
     add_action($tag, array(&$a, 'action'));
     $context = array(rand_str() => rand_str());
     do_action($tag, $context);
     $args = $a->get_args();
     $this->assertSame($args[0][0], $context);
     $context2 = array(rand_str() => rand_str(), rand_str() => rand_str());
     do_action($tag, $context2);
     $args = $a->get_args();
     $this->assertSame($args[1][0], $context2);
 }
Beispiel #3
0
 /**
  * @ticket 12723
  */
 function test_filter_ref_array_result()
 {
     $obj = new stdClass();
     $a = new MockAction();
     $b = new MockAction();
     $tag = rand_str();
     add_action($tag, array($a, 'filter_append'), 10, 2);
     add_action($tag, array($b, 'filter_append'), 10, 2);
     $result = apply_filters_ref_array($tag, array('string', &$obj));
     $this->assertEquals($result, 'string_append_append');
     $args = $a->get_args();
     $this->assertSame($args[0][1], $obj);
     // just in case we don't trust assertSame
     $obj->foo = true;
     $this->assertFalse(empty($args[0][1]->foo));
     $args = $b->get_args();
     $this->assertSame($args[0][1], $obj);
     // just in case we don't trust assertSame
     $obj->foo = true;
     $this->assertFalse(empty($args[0][1]->foo));
 }
 /**
  * @ticket 35598
  */
 public function test_phpmailer_exception_thrown()
 {
     $to = 'an_invalid_address';
     $subject = 'Testing';
     $message = 'Test Message';
     $ma = new MockAction();
     add_action('wp_mail_failed', array(&$ma, 'action'));
     wp_mail($to, $subject, $message);
     $this->assertEquals(1, $ma->get_call_count());
     $expected_error_data = array('to' => array('an_invalid_address'), 'subject' => 'Testing', 'message' => 'Test Message', 'headers' => array(), 'attachments' => array(), 'phpmailer_exception_code' => 2);
     //Retrieve the arguments passed to the 'wp_mail_failed' hook callbacks
     $all_args = $ma->get_args();
     $call_args = array_pop($all_args);
     $this->assertEquals('wp_mail_failed', $call_args[0]->get_error_code());
     $this->assertEquals($expected_error_data, $call_args[0]->get_error_data());
 }
 /**
  * @ticket 11241
  */
 function test_action_keyed_array()
 {
     $a = new MockAction();
     $tag = __FUNCTION__;
     add_action($tag, array(&$a, 'action'));
     $context = array('key1' => 'val1');
     do_action($tag, $context);
     $args = $a->get_args();
     $this->assertSame($args[0][0], $context);
     $context2 = array('key2' => 'val2', 'key3' => 'val3');
     do_action($tag, $context2);
     $args = $a->get_args();
     $this->assertSame($args[1][0], $context2);
 }