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
This commit is contained in:
parent
4fe8c11cd6
commit
3d6c1e5ca2
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user