Make WordPress Core

Changeset 70 in tests


Ignore:
Timestamp:
11/02/2007 06:29:57 AM (16 years ago)
Author:
tellyworth
Message:

improve MockAction

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testlib/utils.php

    r58 r70  
    2424class MockAction {
    2525    var $events;
    26 
    27     function MockAction() {
     26    var $debug;
     27
     28    function MockAction($debug=0) {
    2829        $this->reset();
     30        $this->debug = $debug;
    2931    }
    3032
     
    3234        $this->events = array();
    3335    }
     36   
     37    function current_filter() {
     38        if (is_callable('current_filter'))
     39            return current_filter();
     40        global $wp_actions;
     41        return end($wp_actions);
     42    }
    3443
    3544    function action($arg) {
    36         global $wp_current_action;
    37 
    38         $args = func_get_args();
    39         $this->events[] = array('action' => __FUNCTION__, 'tag'=>$wp_current_action, 'args'=>$args);
     45if ($this->debug) dmp(__FUNCTION__, $this->current_filter());
     46        $args = func_get_args();
     47        $this->events[] = array('action' => __FUNCTION__, 'tag'=>$this->current_filter(), 'args'=>$args);
    4048        return $arg;
    4149    }
    4250
    4351    function action2($arg) {
    44         global $wp_current_action;
    45 
    46         $args = func_get_args();
    47         $this->events[] = array('action' => __FUNCTION__, 'tag'=>$wp_current_action, 'args'=>$args);
     52if ($this->debug) dmp(__FUNCTION__, $this->current_filter());
     53
     54        $args = func_get_args();
     55        $this->events[] = array('action' => __FUNCTION__, 'tag'=>$this->current_filter(), 'args'=>$args);
    4856        return $arg;
    4957    }
    5058
    5159    function filter($arg) {
    52         global $wp_current_filter;
    53 
    54         $args = func_get_args();
    55         $this->events[] = array('filter' => __FUNCTION__, 'tag'=>$wp_current_filter, 'args'=>$args);
     60if ($this->debug) dmp(__FUNCTION__, $this->current_filter());
     61
     62        $args = func_get_args();
     63        $this->events[] = array('filter' => __FUNCTION__, 'tag'=>$this->current_filter(), 'args'=>$args);
    5664        return $arg;
    5765    }
    5866
    5967    function filter2($arg) {
    60         global $wp_current_filter;
    61 
    62         $args = func_get_args();
    63         $this->events[] = array('filter' => __FUNCTION__, 'tag'=>$wp_current_filter, 'args'=>$args);
     68if ($this->debug) dmp(__FUNCTION__, $this->current_filter());
     69
     70        $args = func_get_args();
     71        $this->events[] = array('filter' => __FUNCTION__, 'tag'=>$this->current_filter(), 'args'=>$args);
    6472        return $arg;
    6573    }
Note: See TracChangeset for help on using the changeset viewer.