Ticket #10441: 10441.4.diff
File 10441.4.diff, 4.5 KB (added by , 8 years ago) |
---|
-
src/wp-includes/plugin.php
674 674 */ 675 675 function apply_filters_deprecated( $tag, $args, $version, $replacement = false, $message = null ) { 676 676 if ( ! has_filter( $tag ) ) { 677 return ;677 return $args[0]; 678 678 } 679 679 680 680 _deprecated_hook( $tag, $version, $replacement, $message ); -
tests/phpunit/tests/actions.php
364 364 _backup_plugin_globals(); 365 365 366 366 $wp_actions = array(); 367 367 368 368 $this->assertEmpty( $wp_actions ); 369 369 _restore_plugin_globals(); 370 370 … … 383 383 $a = new MockAction(); 384 384 $tag = rand_str(); 385 385 add_action($tag, array(&$a, 'action')); 386 386 387 387 $this->assertNotEquals( $GLOBALS['wp_filter'], $original_filter ); 388 388 389 389 _restore_plugin_globals(); … … 458 458 $p1->post_title = 'Bar1'; 459 459 $p2->post_title = 'Bar2'; 460 460 } 461 462 /**463 * @ticket 10441464 * @expectedDeprecated tests_apply_filters_deprecated465 */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 10441483 * @expectedDeprecated tests_apply_filters_deprecated484 */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 }505 461 } -
tests/phpunit/tests/filters.php
315 315 $the_ = current( $filters ); 316 316 $this->assertEquals( $the_['function'], array( $this, '_action_test_has_filter_doesnt_reset_wp_filter' ) ); 317 317 } 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 } 362 363 /** 364 * @ticket 10441 365 * @expectedDeprecated tests_apply_filters_deprecated 366 */ 367 public function test_apply_filters_deprecated_without_filter() { 368 $val = 'Foobar'; 369 370 $this->assertSame( $val, apply_filters_deprecated( 'tests_apply_filters_deprecated', array( $val ), '4.6' ) ); 371 } 318 372 }