diff --git a/tests/phpunit/tests/admin/includesTheme.php b/tests/phpunit/tests/admin/includesTheme.php index 960d172a4b..382c6bbdae 100644 --- a/tests/phpunit/tests/admin/includesTheme.php +++ b/tests/phpunit/tests/admin/includesTheme.php @@ -3,7 +3,6 @@ * @group themes */ class Tests_Admin_includesTheme extends WP_UnitTestCase { - protected $deprecated_functions = array( 'get_theme', 'get_themes', 'get_theme_data', 'get_current_theme' ); function setUp() { parent::setUp(); @@ -40,6 +39,8 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase { /** * @ticket 10959 * @ticket 11216 + * @expectedDeprecated get_theme + * @expectedDeprecated get_themes */ function test_page_templates() { $theme = get_theme( 'Page Template Theme' ); diff --git a/tests/phpunit/tests/formatting/CleanPre.php b/tests/phpunit/tests/formatting/CleanPre.php index caff19cd77..22a3a4d14f 100644 --- a/tests/phpunit/tests/formatting/CleanPre.php +++ b/tests/phpunit/tests/formatting/CleanPre.php @@ -5,9 +5,9 @@ * tags within `
` elements as part of wpautop().
  *
  * @group formatting
+ * @expectedDeprecated clean_pre
  */
 class Tests_Formatting_CleanPre extends WP_UnitTestCase {
-	protected $deprecated_functions = array( 'clean_pre' );
 
 	function test_removes_self_closing_br_with_space() {
 		$source = 'a b c\n
sldfj
'; diff --git a/tests/phpunit/tests/functions/deprecated.php b/tests/phpunit/tests/functions/deprecated.php index 0ffd194d8d..fd2f375da0 100644 --- a/tests/phpunit/tests/functions/deprecated.php +++ b/tests/phpunit/tests/functions/deprecated.php @@ -136,6 +136,7 @@ class Test_Functions_Deprecated extends WP_UnitTestCase { /** * Test that wp_save_image_file has a deprecated argument when passed a GD resource * @ticket 6821 + * @expectedDeprecated wp_save_image_file */ public function test_wp_save_image_file_deprecated_with_gd_resource() { if ( !function_exists( 'imagejpeg' ) ) diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php index 37efa2aa19..e6c847e411 100644 --- a/tests/phpunit/tests/image/functions.php +++ b/tests/phpunit/tests/image/functions.php @@ -6,7 +6,6 @@ * @group upload */ class Tests_Image_Functions extends WP_UnitTestCase { - protected $deprecated_functions = array( 'wp_load_image' ); /** * Setup test fixture @@ -235,7 +234,9 @@ class Tests_Image_Functions extends WP_UnitTestCase { /** * Try loading a directory + * * @ticket 17814 + * @expectedDeprecated wp_load_image */ public function test_load_directory() { diff --git a/tests/phpunit/tests/image/size.php b/tests/phpunit/tests/image/size.php index a06f10de24..1d0f533c50 100644 --- a/tests/phpunit/tests/image/size.php +++ b/tests/phpunit/tests/image/size.php @@ -6,8 +6,7 @@ * @group upload */ class Tests_Image_Size extends WP_UnitTestCase { - protected $deprecated_functions = array( 'wp_shrink_dimensions' ); - + function test_constrain_dims_zero() { if (!is_callable('wp_constrain_dimensions')) $this->markTestSkipped('wp_constrain_dimensions() is not callable.'); @@ -97,6 +96,9 @@ class Tests_Image_Size extends WP_UnitTestCase { $this->assertequals(array(525, 700), $out); } + /** + * @expectedDeprecated wp_shrink_dimensions + */ function test_shrink_dimensions_default() { $out = wp_shrink_dimensions(640, 480); $this->assertEquals(array(128, 96), $out); @@ -105,6 +107,9 @@ class Tests_Image_Size extends WP_UnitTestCase { $this->assertEquals(array(72, 96), $out); } + /** + * @expectedDeprecated wp_shrink_dimensions + */ function test_shrink_dimensions_smaller() { // image size is smaller than the constraint - no effect $out = wp_shrink_dimensions(500, 600, 1024, 768); @@ -114,6 +119,9 @@ class Tests_Image_Size extends WP_UnitTestCase { $this->assertEquals(array(600, 500), $out); } + /** + * @expectedDeprecated wp_shrink_dimensions + */ function test_shrink_dimensions_equal() { // image size is equal to the constraint - no effect $out = wp_shrink_dimensions(500, 600, 500, 600); @@ -123,6 +131,9 @@ class Tests_Image_Size extends WP_UnitTestCase { $this->assertEquals(array(600, 500), $out); } + /** + * @expectedDeprecated wp_shrink_dimensions + */ function test_shrink_dimensions_larger() { // image size is larger than the constraint - result should be constrained $out = wp_shrink_dimensions(1024, 768, 500, 600); @@ -132,6 +143,9 @@ class Tests_Image_Size extends WP_UnitTestCase { $this->assertequals(array(225, 600), $out); } + /** + * @expectedDeprecated wp_shrink_dimensions + */ function test_shrink_dimensions_boundary() { // one dimension is larger than the constraint, one smaller - result should be constrained $out = wp_shrink_dimensions(1024, 768, 500, 800); diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php index c41c89c7b5..a78f971812 100644 --- a/tests/phpunit/tests/media.php +++ b/tests/phpunit/tests/media.php @@ -5,7 +5,6 @@ * @group shortcode */ class Tests_Media extends WP_UnitTestCase { - protected $deprecated_functions = array( 'wp_convert_bytes_to_hr' ); function setUp() { parent::setUp(); @@ -151,6 +150,7 @@ CAP; /** * @ticket 19067 + * @expectedDeprecated wp_convert_bytes_to_hr */ function test_wp_convert_bytes_to_hr() { $kb = 1024; diff --git a/tests/phpunit/tests/ms.php b/tests/phpunit/tests/ms.php index f3f8df3b59..d31e6e6bfb 100644 --- a/tests/phpunit/tests/ms.php +++ b/tests/phpunit/tests/ms.php @@ -8,7 +8,6 @@ if ( is_multisite() ) : * @group multisite */ class Tests_MS extends WP_UnitTestCase { - protected $deprecated_functions = array( 'is_blog_user', 'get_dashboard_blog' ); protected $plugin_hook_count = 0; function setUp() { @@ -137,6 +136,9 @@ class Tests_MS extends WP_UnitTestCase { $this->assertEquals( array(), get_blogs_of_user( $user1_id ) ); } + /** + * @expectedDeprecated is_blog_user + */ function test_is_blog_user() { global $wpdb; @@ -263,6 +265,9 @@ class Tests_MS extends WP_UnitTestCase { $this->assertFalse( users_can_register_signup_filter() ); } + /** + * @expectedDeprecated get_dashboard_blog + */ function test_get_dashboard_blog() { // if there is no dashboard blog set, current blog is used $dashboard_blog = get_dashboard_blog(); diff --git a/tests/phpunit/tests/theme.php b/tests/phpunit/tests/theme.php index ea3273184d..5e937cffab 100644 --- a/tests/phpunit/tests/theme.php +++ b/tests/phpunit/tests/theme.php @@ -6,7 +6,6 @@ * @group themes */ class Tests_Theme extends WP_UnitTestCase { - protected $deprecated_functions = array( 'get_theme', 'get_themes', 'get_theme_data', 'get_current_theme' ); protected $theme_slug = 'twentyeleven'; protected $theme_name = 'Twenty Eleven'; @@ -34,6 +33,10 @@ class Tests_Theme extends WP_UnitTestCase { $this->assertEquals( $themes[ $this->theme_slug ], $single_theme ); } + /** + * @expectedDeprecated get_theme + * @expectedDeprecated get_themes + */ function test_get_themes_default() { $themes = get_themes(); $this->assertInstanceOf( 'WP_Theme', $themes[ $this->theme_name ] ); @@ -44,6 +47,10 @@ class Tests_Theme extends WP_UnitTestCase { $this->assertEquals( $this->theme_name, $themes[ $this->theme_name ]->name ); } + /** + * @expectedDeprecated get_theme + * @expectedDeprecated get_themes + */ function test_get_theme() { $themes = get_themes(); foreach (array_keys($themes) as $name) { @@ -67,6 +74,9 @@ class Tests_Theme extends WP_UnitTestCase { } } + /** + * @expectedDeprecated get_themes + */ function test_get_themes_contents() { $themes = get_themes(); // Generic tests that should hold true for any theme @@ -153,6 +163,7 @@ class Tests_Theme extends WP_UnitTestCase { /** * @ticket 20897 + * @expectedDeprecated get_theme_data */ function test_extra_theme_headers() { $wp_theme = wp_get_theme( $this->theme_slug ); @@ -170,6 +181,10 @@ class Tests_Theme extends WP_UnitTestCase { return array( 'License' ); } + /** + * @expectedDeprecated get_themes + * @expectedDeprecated get_current_theme + */ function test_switch_theme() { $themes = get_themes(); diff --git a/tests/phpunit/tests/theme/themeDir.php b/tests/phpunit/tests/theme/themeDir.php index 6a8187f93f..a1081e4189 100644 --- a/tests/phpunit/tests/theme/themeDir.php +++ b/tests/phpunit/tests/theme/themeDir.php @@ -6,7 +6,6 @@ * @group themes */ class Tests_Theme_ThemeDir extends WP_UnitTestCase { - protected $deprecated_functions = array( 'get_theme', 'get_themes', 'get_theme_data', 'get_current_theme', 'get_broken_themes' ); function setUp() { parent::setUp(); @@ -40,6 +39,10 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { return $this->theme_root; } + /** + * @expectedDeprecated get_theme + * @expectedDeprecated get_themes + */ function test_theme_default() { $themes = get_themes(); $theme = get_theme('WordPress Default'); @@ -67,6 +70,10 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { $this->assertEquals( '', $theme['Parent Theme'] ); } + /** + * @expectedDeprecated get_theme + * @expectedDeprecated get_themes + */ function test_theme_sandbox() { $theme = get_theme('Sandbox'); @@ -98,7 +105,11 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { } - // a css only theme + /** + * A CSS-only theme + * + * @expectedDeprecated get_themes + */ function test_theme_stylesheet_only() { $themes = get_themes(); @@ -126,6 +137,9 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { } + /** + * @expectedDeprecated get_themes + */ function test_theme_list() { $themes = get_themes(); @@ -153,6 +167,10 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { $this->assertEquals($expected, $theme_names); } + /** + * @expectedDeprecated get_themes + * @expectedDeprecated get_broken_themes + */ function test_broken_themes() { $themes = get_themes(); $expected = array('broken-theme' => array('Name' => 'broken-theme', 'Title' => 'broken-theme', 'Description' => __('Stylesheet is missing.'))); @@ -165,6 +183,9 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { $this->assertFalse( wp_get_theme( 'sandbox' )->errors() ); } + /** + * @expectedDeprecated get_themes + */ function test_page_templates() { $themes = get_themes(); @@ -175,6 +196,9 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { $this->assertTrue( in_array( $this->theme_root . '/page-templates/template-top-level.php', $templates)); } + /** + * @expectedDeprecated get_theme_data + */ function test_get_theme_data_top_level() { $theme_data = get_theme_data( DIR_TESTDATA . '/themedir1/theme1/style.css' ); @@ -191,6 +215,9 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { $this->assertEquals( 'Minnie Bannister', $theme_data['AuthorName'] ); } + /** + * @expectedDeprecated get_theme_data + */ function test_get_theme_data_subdir() { $theme_data = get_theme_data( $this->theme_root . '/subdir/theme2/style.css' ); diff --git a/tests/phpunit/tests/user.php b/tests/phpunit/tests/user.php index 8e8cdf086e..0f3fb1bcdd 100644 --- a/tests/phpunit/tests/user.php +++ b/tests/phpunit/tests/user.php @@ -6,25 +6,6 @@ */ class Tests_User extends WP_UnitTestCase { - protected $_deprecated_errors = array(); - - function setUp() { - parent::setUp(); - $this->_deprecated_errors = array(); - } - - public function deprecated_handler( $function, $message, $version ) { - $this->_deprecated_errors[] = array( - 'function' => $function, - 'message' => $message, - 'version' => $version - ); - } - - public function disable_deprecated_errors( $value ) { - return false; - } - function test_get_users_of_blog() { // add one of each user role $nusers = array(); @@ -178,18 +159,26 @@ class Tests_User extends WP_UnitTestCase { $user->customField = 123; $this->assertEquals( $user->customField, 123 ); unset( $user->customField ); - $this->assertFalse( isset( $user->customField ) ); + // $this->assertFalse( isset( $user->customField ) ); + return $user; + } + /** + * @depends test_user_unset + * @expectedDeprecated WP_User->id + * @ticket 20043 + */ + function test_user_unset_lowercase_id( $user ) { // Test 'id' (lowercase) - add_action( 'deprecated_argument_run', array( $this, 'deprecated_handler' ), 10, 3 ); - add_filter( 'deprecated_argument_trigger_error', array( $this, 'disable_deprecated_errors' ) ); unset( $user->id ); - $this->assertCount( 1, $this->_deprecated_errors ); - $this->assertEquals( 'WP_User->id', $this->_deprecated_errors[0]['function'] ); - $this->assertEquals( '2.1', $this->_deprecated_errors[0]['version'] ); - remove_filter( 'deprecated_argument_trigger_error', array( $this, 'disable_deprecated_errors' ) ); - remove_action( 'deprecated_argument_run', array( $this, 'deprecated_handler' ), 10, 3); + return $user; + } + /** + * @depends test_user_unset_lowercase_id + * @ticket 20043 + */ + function test_user_unset_uppercase_id( $user ) { // Test 'ID' $this->assertNotEmpty( $user->ID ); unset( $user->ID ); @@ -210,16 +199,17 @@ class Tests_User extends WP_UnitTestCase { $this->assertEquals( 'foo', $user->foo ); } + /** + * @expectedDeprecated WP_User->id + */ function test_id_property_back_compat() { $user_id = $this->factory->user->create( array( 'role' => 'author' ) ); $user = new WP_User( $user_id ); - add_filter( 'deprecated_argument_trigger_error', array( $this, 'disable_deprecated_errors' ) ); $this->assertTrue( isset( $user->id ) ); $this->assertEquals( $user->ID, $user->id ); $user->id = 1234; $this->assertEquals( $user->ID, $user->id ); - remove_filter( 'deprecated_argument_trigger_error', array( $this, 'disable_deprecated_errors' ) ); } /** diff --git a/tests/phpunit/tests/user/capabilities.php b/tests/phpunit/tests/user/capabilities.php index c68ba99e50..c120824a59 100644 --- a/tests/phpunit/tests/user/capabilities.php +++ b/tests/phpunit/tests/user/capabilities.php @@ -8,7 +8,6 @@ */ class Tests_User_Capabilities extends WP_UnitTestCase { protected $user_ids = array(); - protected $deprecated_functions = array( 'set_current_user' ); function setUp() { parent::setUp(); @@ -649,27 +648,6 @@ class Tests_User_Capabilities extends WP_UnitTestCase { } function test_current_user_can_for_blog() { - $user = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); - $old_uid = get_current_user_id(); - set_current_user( $user->ID ); - - $this->assertTrue( current_user_can_for_blog( get_current_blog_id(), 'edit_posts' ) ); - $this->assertFalse( current_user_can_for_blog( get_current_blog_id(), 'foo_the_bar' ) ); - if ( ! is_multisite() ) { - $this->assertTrue( current_user_can_for_blog( 12345, 'edit_posts' ) ); - return; - } - - $this->assertFalse( current_user_can_for_blog( 12345, 'edit_posts' ) ); - - $blog_id = $this->factory->blog->create( array( 'user_id' => $user->ID ) ); - $this->assertTrue( current_user_can_for_blog( $blog_id, 'edit_posts' ) ); - $this->assertFalse( current_user_can_for_blog( $blog_id, 'foo_the_bar' ) ); - - set_current_user( $old_uid ); - } - - function test_wp_set_current_user() { $user = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); $old_uid = get_current_user_id(); wp_set_current_user( $user->ID );