WordPress.org

Make WordPress Core

Changeset 37909


Ignore:
Timestamp:
06/29/2016 01:13:53 PM (2 years ago)
Author:
ocean90
Message:

Tests: After [37861] move tests for deprecated filters into filters.php.

See #10441.

Location:
trunk/tests/phpunit/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/actions.php

    r37861 r37909  
    365365
    366366        $wp_actions = array();
    367        
     367
    368368        $this->assertEmpty( $wp_actions );
    369369        _restore_plugin_globals();
     
    384384        $tag = rand_str();
    385385        add_action($tag, array(&$a, 'action'));
    386        
     386
    387387        $this->assertNotEquals( $GLOBALS['wp_filter'], $original_filter );
    388388
     
    459459        $p2->post_title = 'Bar2';
    460460    }
    461 
    462     /**
    463      * @ticket 10441
    464      * @expectedDeprecated tests_apply_filters_deprecated
    465      */
    466     public function test_apply_filters_deprecated() {
    467         $p = 'Foo';
    468 
    469         add_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback' ) );
    470         $p = apply_filters_deprecated( 'tests_apply_filters_deprecated', array( $p ), '4.6' );
    471         remove_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback' ) );
    472 
    473         $this->assertSame( 'Bar', $p );
    474     }
    475 
    476     public static function deprecated_filter_callback( $p ) {
    477         $p = 'Bar';
    478         return $p;
    479     }
    480 
    481     /**
    482      * @ticket 10441
    483      * @expectedDeprecated tests_apply_filters_deprecated
    484      */
    485     public function test_apply_filters_deprecated_with_multiple_params() {
    486         $p1 = 'Foo1';
    487         $p2 = 'Foo2';
    488 
    489         add_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback_multiple_params' ), 10, 2 );
    490         $p1 = apply_filters_deprecated( 'tests_apply_filters_deprecated', array( $p1, $p2 ), '4.6' );
    491         remove_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback_multiple_params' ), 10, 2 );
    492 
    493         $this->assertSame( 'Bar1', $p1 );
    494 
    495         // Not passed by reference, so not modified.
    496         $this->assertSame( 'Foo2', $p2 );
    497     }
    498 
    499     public static function deprecated_filter_callback_multiple_params( $p1, $p2 ) {
    500         $p1 = 'Bar1';
    501         $p2 = 'Bar2';
    502 
    503         return $p1;
    504     }
    505461}
  • trunk/tests/phpunit/tests/filters.php

    r31014 r37909  
    316316        $this->assertEquals( $the_['function'], array( $this, '_action_test_has_filter_doesnt_reset_wp_filter' ) );
    317317     }
     318
     319    /**
     320     * @ticket 10441
     321     * @expectedDeprecated tests_apply_filters_deprecated
     322     */
     323    public function test_apply_filters_deprecated() {
     324        $p = 'Foo';
     325
     326        add_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback' ) );
     327        $p = apply_filters_deprecated( 'tests_apply_filters_deprecated', array( $p ), '4.6' );
     328        remove_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback' ) );
     329
     330        $this->assertSame( 'Bar', $p );
     331    }
     332
     333    public static function deprecated_filter_callback( $p ) {
     334        $p = 'Bar';
     335        return $p;
     336    }
     337
     338    /**
     339     * @ticket 10441
     340     * @expectedDeprecated tests_apply_filters_deprecated
     341     */
     342    public function test_apply_filters_deprecated_with_multiple_params() {
     343        $p1 = 'Foo1';
     344        $p2 = 'Foo2';
     345
     346        add_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback_multiple_params' ), 10, 2 );
     347        $p1 = apply_filters_deprecated( 'tests_apply_filters_deprecated', array( $p1, $p2 ), '4.6' );
     348        remove_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback_multiple_params' ), 10, 2 );
     349
     350        $this->assertSame( 'Bar1', $p1 );
     351
     352        // Not passed by reference, so not modified.
     353        $this->assertSame( 'Foo2', $p2 );
     354    }
     355
     356    public static function deprecated_filter_callback_multiple_params( $p1, $p2 ) {
     357        $p1 = 'Bar1';
     358        $p2 = 'Bar2';
     359
     360        return $p1;
     361    }
    318362}
Note: See TracChangeset for help on using the changeset viewer.