Make WordPress Core


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

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

See #10441.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.