Make WordPress Core

Changeset 867 in tests for trunk/wp-testcase/test_option.php


Ignore:
Timestamp:
07/02/2012 06:35:48 PM (12 years ago)
Author:
nacin
Message:

Remove closures from test_option.php. see #101.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-testcase/test_option.php

    r786 r867  
    1111    function tearDown() {
    1212        parent::tearDown();
     13    }
     14
     15    function __return_foo() {
     16        return 'foo';   
    1317    }
    1418
     
    3943
    4044    function test_default_filter() {
    41         $return_foo = function ( $value ) {
    42             return 'foo';
    43         };
    44 
    4545        $random = rand_str();
    4646
     
    4848
    4949        // Default filter overrides $default arg.
    50         add_filter( 'default_option_doesnotexist', $return_foo );
     50        add_filter( 'default_option_doesnotexist', array( $this, '__return_foo' ) );
    5151        $this->assertEquals( 'foo', get_option( 'doesnotexist', 'bar' ) );
    5252
    5353        // Remove the filter and the $default arg is honored.
    54         remove_filter( 'default_option_doesnotexist', $return_foo );
     54        remove_filter( 'default_option_doesnotexist', array( $this, '__return_foo' ) );
    5555        $this->assertEquals( 'bar', get_option( 'doesnotexist', 'bar' ) );
    5656
     
    5858        add_option( 'doesnotexist', $random );
    5959        $this->assertEquals( $random, get_option( 'doesnotexist', 'foo' ) );
    60         add_filter( 'default_option_doesnotexist', $return_foo );
     60        add_filter( 'default_option_doesnotexist', array( $this, '__return_foo' ) );
    6161        $this->assertEquals( $random, get_option( 'doesnotexist', 'foo' ) );
    62         remove_filter( 'default_option_doesnotexist', $return_foo );
     62        remove_filter( 'default_option_doesnotexist', array( $this, '__return_foo' ) );
    6363
    6464        // Cleanup
     
    8585 */
    8686class TestSiteOption extends WP_UnitTestCase {
    87     function setUp() {
    88         parent::setUp();
    89     }
    90 
    91     function tearDown() {
    92         parent::tearDown();
     87    function __return_foo() {
     88        return 'foo';   
    9389    }
    9490
     
    119115
    120116    function test_default_filter() {
    121         $return_foo = function ( $value ) {
    122             return 'foo';
    123         };
    124 
    125117        $random = rand_str();
    126118
     
    128120
    129121        // Default filter overrides $default arg.
    130         add_filter( 'default_site_option_doesnotexist', $return_foo );
     122        add_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) );
    131123        $this->assertEquals( 'foo', get_site_option( 'doesnotexist', 'bar' ) );
    132124
    133125        // Remove the filter and the $default arg is honored.
    134         remove_filter( 'default_site_option_doesnotexist', $return_foo );
     126        remove_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) );
    135127        $this->assertEquals( 'bar', get_site_option( 'doesnotexist', 'bar' ) );
    136128
     
    138130        add_site_option( 'doesnotexist', $random );
    139131        $this->assertEquals( $random, get_site_option( 'doesnotexist', 'foo' ) );
    140         add_filter( 'default_site_option_doesnotexist', $return_foo );
     132        add_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) );
    141133        $this->assertEquals( $random, get_site_option( 'doesnotexist', 'foo' ) );
    142         remove_filter( 'default_site_option_doesnotexist', $return_foo );
     134        remove_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) );
    143135
    144136        // Cleanup
Note: See TracChangeset for help on using the changeset viewer.