Make WordPress Core

Changeset 78 in tests


Ignore:
Timestamp:
11/08/2007 01:26:12 AM (18 years ago)
Author:
tellyworth
Message:

update filter/action tests for wporg r6324

Location:
wp-testcase
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_actions.php

    r77 r78  
    44
    55class WPTestActions extends WPTestCase {
    6     var $_old_filters;
    7 
    8     function setUp() {
    9         #$this->_old_filters = $GLOBALS['wp_filter'];
    10     }
    11 
    12     function tearDown() {
    13         #$GLOBALS['wp_filter'] = $this->_old_filters;
    14     }
    156
    167    function test_simple_action() {
     
    151142
    152143    function test_all_action() {
    153         $a = new MockAction(1);
     144        $a = new MockAction();
    154145        $tag1 = rand_str();
    155146        $tag2 = rand_str();
  • wp-testcase/test_filters.php

    r77 r78  
    44
    55class WPTestFilters extends WPTestCase {
    6     var $_old_filters;
    7 
    8     function setUp() {
    9         $this->_old_filters = $GLOBALS['wp_filter'];
    10         unset($GLOBALS['merged_filters']);
    11         // this screws up filter priorities
    12         unset($GLOBALS['wp_filter']['all']);
    13     }
    14 
    15     function tearDown() {
    16         $GLOBALS['wp_filter'] = $this->_old_filters;
    17     }
    186
    197    function test_simple_filter() {
     
    144132        $tag1 = rand_str();
    145133        $tag2 = rand_str();
     134        $val = rand_str();
    146135
    147136        // add an 'all' filter
    148         add_filter('all', array(&$a, 'filter'));
     137        add_filter('all', array(&$a, 'filterall'));
    149138        // do some filters
    150139        $this->assertEquals($val, apply_filters($tag1, $val));
     
    158147        $this->assertEquals(array($tag1, $tag2, $tag1, $tag1), $a->get_tags());
    159148
     149        remove_filter('all', array(&$a, 'filterall'));
     150
    160151    }
    161152
     
    165156        $val = rand_str();
    166157
    167         add_filter('all', array(&$a, 'filter'));
    168         $this->assertEquals($val, apply_filters($tag1, $val));
     158        add_filter('all', array(&$a, 'filterall'));
     159        $this->assertEquals($val, apply_filters($tag, $val));
    169160
    170161        // make sure our hook was called correctly
     
    173164
    174165        // now remove the filter, do it again, and make sure it's not called this time
    175         remove_filter('all', array(&$a, 'filter'));
    176         $this->assertEquals($val, apply_filters($tag1, $val));
     166        remove_filter('all', array(&$a, 'filterall'));
     167        $this->assertEquals($val, apply_filters($tag, $val));
    177168        // call cound should remain at 1
    178169        $this->assertEquals(1, $a->get_call_count());
Note: See TracChangeset for help on using the changeset viewer.