WordPress.org

Make WordPress Core

Changeset 294 in tests


Ignore:
Timestamp:
03/31/10 21:32:56 (4 years ago)
Author:
westi
Message:

Add an extra test for apply_filters_ref_array to test the result of the filter. See WP#12723

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_filters.php

    r293 r294  
    196196        $tag = rand_str(); 
    197197 
    198         add_action($tag, array(&$a, 'action')); 
     198        add_action($tag, array(&$a, 'filter')); 
    199199 
    200200        apply_filters_ref_array($tag, array(&$obj)); 
     
    206206        $this->assertFalse( empty($args[0][0]->foo) ); 
    207207    } 
     208 
     209    function test_filter_ref_array_result() { 
     210        $this->knownWPBug(12723); 
     211        $obj = new stdClass(); 
     212        $a = new MockAction(); 
     213        $tag = rand_str(); 
     214 
     215        add_action($tag, array(&$a, 'filter_append'), 10, 2); 
     216 
     217        $result = apply_filters_ref_array($tag, array('string', &$obj)); 
     218 
     219        $this->assertEquals($result, 'string_append'); 
     220         
     221        $args = $a->get_args(); 
     222 
     223        $this->assertSame($args[0][1], $obj); 
     224        // just in case we don't trust assertSame 
     225        $obj->foo = true; 
     226        $this->assertFalse( empty($args[0][1]->foo) ); 
     227    } 
    208228} 
    209229 
  • wp-testlib/utils.php

    r289 r294  
    7171        $this->events[] = array('filter' => __FUNCTION__, 'tag'=>$this->current_filter(), 'args'=>$args); 
    7272        return $arg; 
     73    } 
     74 
     75    function filter_append($arg) { 
     76if ($this->debug) dmp(__FUNCTION__, $this->current_filter()); 
     77 
     78        $args = func_get_args(); 
     79        $this->events[] = array('filter' => __FUNCTION__, 'tag'=>$this->current_filter(), 'args'=>$args); 
     80        return $arg . '_append'; 
    7381    } 
    7482 
Note: See TracChangeset for help on using the changeset viewer.