From 3d6c1e5ca287fbb19a7ad2ae308cb6d89f674f93 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Wed, 29 Jun 2016 13:13:53 +0000 Subject: [PATCH] Tests: After [37861] move tests for deprecated filters into `filters.php`. See #10441. git-svn-id: https://develop.svn.wordpress.org/trunk@37909 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/actions.php | 48 ++------------------------------- tests/phpunit/tests/filters.php | 44 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/tests/phpunit/tests/actions.php b/tests/phpunit/tests/actions.php index 4b2f9c7118..b02e2adcc9 100644 --- a/tests/phpunit/tests/actions.php +++ b/tests/phpunit/tests/actions.php @@ -364,7 +364,7 @@ class Tests_Actions extends WP_UnitTestCase { _backup_plugin_globals(); $wp_actions = array(); - + $this->assertEmpty( $wp_actions ); _restore_plugin_globals(); @@ -383,7 +383,7 @@ class Tests_Actions extends WP_UnitTestCase { $a = new MockAction(); $tag = rand_str(); add_action($tag, array(&$a, 'action')); - + $this->assertNotEquals( $GLOBALS['wp_filter'], $original_filter ); _restore_plugin_globals(); @@ -458,48 +458,4 @@ class Tests_Actions extends WP_UnitTestCase { $p1->post_title = 'Bar1'; $p2->post_title = 'Bar2'; } - - /** - * @ticket 10441 - * @expectedDeprecated tests_apply_filters_deprecated - */ - public function test_apply_filters_deprecated() { - $p = 'Foo'; - - add_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback' ) ); - $p = apply_filters_deprecated( 'tests_apply_filters_deprecated', array( $p ), '4.6' ); - remove_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback' ) ); - - $this->assertSame( 'Bar', $p ); - } - - public static function deprecated_filter_callback( $p ) { - $p = 'Bar'; - return $p; - } - - /** - * @ticket 10441 - * @expectedDeprecated tests_apply_filters_deprecated - */ - public function test_apply_filters_deprecated_with_multiple_params() { - $p1 = 'Foo1'; - $p2 = 'Foo2'; - - add_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback_multiple_params' ), 10, 2 ); - $p1 = apply_filters_deprecated( 'tests_apply_filters_deprecated', array( $p1, $p2 ), '4.6' ); - remove_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback_multiple_params' ), 10, 2 ); - - $this->assertSame( 'Bar1', $p1 ); - - // Not passed by reference, so not modified. - $this->assertSame( 'Foo2', $p2 ); - } - - public static function deprecated_filter_callback_multiple_params( $p1, $p2 ) { - $p1 = 'Bar1'; - $p2 = 'Bar2'; - - return $p1; - } } diff --git a/tests/phpunit/tests/filters.php b/tests/phpunit/tests/filters.php index d9eda55a2b..b0bfcfb547 100644 --- a/tests/phpunit/tests/filters.php +++ b/tests/phpunit/tests/filters.php @@ -315,4 +315,48 @@ class Tests_Filters extends WP_UnitTestCase { $the_ = current( $filters ); $this->assertEquals( $the_['function'], array( $this, '_action_test_has_filter_doesnt_reset_wp_filter' ) ); } + + /** + * @ticket 10441 + * @expectedDeprecated tests_apply_filters_deprecated + */ + public function test_apply_filters_deprecated() { + $p = 'Foo'; + + add_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback' ) ); + $p = apply_filters_deprecated( 'tests_apply_filters_deprecated', array( $p ), '4.6' ); + remove_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback' ) ); + + $this->assertSame( 'Bar', $p ); + } + + public static function deprecated_filter_callback( $p ) { + $p = 'Bar'; + return $p; + } + + /** + * @ticket 10441 + * @expectedDeprecated tests_apply_filters_deprecated + */ + public function test_apply_filters_deprecated_with_multiple_params() { + $p1 = 'Foo1'; + $p2 = 'Foo2'; + + add_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback_multiple_params' ), 10, 2 ); + $p1 = apply_filters_deprecated( 'tests_apply_filters_deprecated', array( $p1, $p2 ), '4.6' ); + remove_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback_multiple_params' ), 10, 2 ); + + $this->assertSame( 'Bar1', $p1 ); + + // Not passed by reference, so not modified. + $this->assertSame( 'Foo2', $p2 ); + } + + public static function deprecated_filter_callback_multiple_params( $p1, $p2 ) { + $p1 = 'Bar1'; + $p2 = 'Bar2'; + + return $p1; + } }