MockAction::get_tags PHP Method

get_tags() public method

return an array of the tags that triggered calls to this action
public get_tags ( )
    function get_tags()
    {
        $out = array();
        foreach ($this->events as $e) {
            $out[] = $e['tag'];
        }
        return $out;
    }

Usage Example

 /**
  * 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());
     }
 }
All Usage Examples Of MockAction::get_tags