Make WordPress Core

Changeset 25409


Ignore:
Timestamp:
09/12/2013 06:37:32 PM (13 years ago)
Author:
nacin
Message:

Use @expectedDeprecated. see #25282, [25408].

Location:
trunk/tests/phpunit/tests
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/admin/includesTheme.php

    r25402 r25409  
    44 */
    55class Tests_Admin_includesTheme extends WP_UnitTestCase {
    6         protected $deprecated_functions = array( 'get_theme', 'get_themes', 'get_theme_data', 'get_current_theme' );
    76
    87        function setUp() {
    … …  
    4140         * @ticket 10959
    4241         * @ticket 11216
     42         * @expectedDeprecated get_theme
     43         * @expectedDeprecated get_themes
    4344         */
    4445        function test_page_templates() {
  • trunk/tests/phpunit/tests/formatting/CleanPre.php

    r25402 r25409  
    66 *
    77 * @group formatting
     8 * @expectedDeprecated clean_pre
    89 */
    910class Tests_Formatting_CleanPre extends WP_UnitTestCase {
    10         protected $deprecated_functions = array( 'clean_pre' );
    1111
    1212        function test_removes_self_closing_br_with_space() {
  • trunk/tests/phpunit/tests/functions/deprecated.php

    r25002 r25409  
    137137         * Test that wp_save_image_file has a deprecated argument when passed a GD resource
    138138         * @ticket 6821
     139         * @expectedDeprecated wp_save_image_file
    139140         */
    140141        public function test_wp_save_image_file_deprecated_with_gd_resource() {
  • trunk/tests/phpunit/tests/image/functions.php

    r25402 r25409  
    77 */
    88class Tests_Image_Functions extends WP_UnitTestCase {
    9         protected $deprecated_functions = array( 'wp_load_image' );
    109
    1110        /**
    … …  
    236235        /**
    237236         * Try loading a directory
     237         *
    238238         * @ticket 17814
     239         * @expectedDeprecated wp_load_image
    239240         */
    240241        public function test_load_directory() {
  • trunk/tests/phpunit/tests/image/size.php

    r25402 r25409  
    77 */
    88class Tests_Image_Size extends WP_UnitTestCase {
    9         protected $deprecated_functions = array( 'wp_shrink_dimensions' );
    10        
     9
    1110        function test_constrain_dims_zero() {
    1211                if (!is_callable('wp_constrain_dimensions'))
    … …  
    9897        }
    9998
     99        /**
     100         * @expectedDeprecated wp_shrink_dimensions
     101         */
    100102        function test_shrink_dimensions_default() {
    101103                $out = wp_shrink_dimensions(640, 480);
    … …  
    106108        }
    107109
     110        /**
     111         * @expectedDeprecated wp_shrink_dimensions
     112         */
    108113        function test_shrink_dimensions_smaller() {
    109114                // image size is smaller than the constraint - no effect
    … …  
    115120        }
    116121
     122        /**
     123         * @expectedDeprecated wp_shrink_dimensions
     124         */
    117125        function test_shrink_dimensions_equal() {
    118126                // image size is equal to the constraint - no effect
    … …  
    124132        }
    125133
     134        /**
     135         * @expectedDeprecated wp_shrink_dimensions
     136         */
    126137        function test_shrink_dimensions_larger() {
    127138                // image size is larger than the constraint - result should be constrained
    … …  
    133144        }
    134145
     146        /**
     147         * @expectedDeprecated wp_shrink_dimensions
     148         */
    135149        function test_shrink_dimensions_boundary() {
    136150                // one dimension is larger than the constraint, one smaller - result should be constrained
  • trunk/tests/phpunit/tests/media.php

    r25402 r25409  
    66 */
    77class Tests_Media extends WP_UnitTestCase {
    8         protected $deprecated_functions = array( 'wp_convert_bytes_to_hr' );
    98
    109        function setUp() {
    … …  
    152151        /**
    153152         * @ticket 19067
     153         * @expectedDeprecated wp_convert_bytes_to_hr
    154154         */
    155155        function test_wp_convert_bytes_to_hr() {
  • trunk/tests/phpunit/tests/ms.php

    r25402 r25409  
    99 */
    1010class Tests_MS extends WP_UnitTestCase {
    11         protected $deprecated_functions = array( 'is_blog_user', 'get_dashboard_blog' );
    1211        protected $plugin_hook_count = 0;
    1312
    … …  
    138137        }
    139138
     139        /**
     140         * @expectedDeprecated is_blog_user
     141         */
    140142        function test_is_blog_user() {
    141143                global $wpdb;
    … …  
    264266        }
    265267
     268        /**
     269         * @expectedDeprecated get_dashboard_blog
     270         */
    266271        function test_get_dashboard_blog() {
    267272                // if there is no dashboard blog set, current blog is used
  • trunk/tests/phpunit/tests/theme.php

    r25402 r25409  
    77 */
    88class Tests_Theme extends WP_UnitTestCase {
    9         protected $deprecated_functions = array( 'get_theme', 'get_themes', 'get_theme_data', 'get_current_theme' );
    109        protected $theme_slug = 'twentyeleven';
    1110        protected $theme_name = 'Twenty Eleven';
    … …  
    3534        }
    3635
     36        /**
     37         * @expectedDeprecated get_theme
     38         * @expectedDeprecated get_themes
     39         */
    3740        function test_get_themes_default() {
    3841                $themes = get_themes();
    … …  
    4548        }
    4649
     50        /**
     51         * @expectedDeprecated get_theme
     52         * @expectedDeprecated get_themes
     53         */
    4754        function test_get_theme() {
    4855                $themes = get_themes();
    … …  
    6875        }
    6976
     77        /**
     78         * @expectedDeprecated get_themes
     79         */
    7080        function test_get_themes_contents() {
    7181                $themes = get_themes();
    … …  
    154164        /**
    155165         * @ticket 20897
     166         * @expectedDeprecated get_theme_data
    156167         */
    157168        function test_extra_theme_headers() {
    … …  
    171182        }
    172183
     184        /**
     185         * @expectedDeprecated get_themes
     186         * @expectedDeprecated get_current_theme
     187         */
    173188        function test_switch_theme() {
    174189                $themes = get_themes();
  • trunk/tests/phpunit/tests/theme/themeDir.php

    r25402 r25409  
    77 */
    88class Tests_Theme_ThemeDir extends WP_UnitTestCase {
    9         protected $deprecated_functions = array( 'get_theme', 'get_themes', 'get_theme_data', 'get_current_theme', 'get_broken_themes' );
    109
    1110        function setUp() {
    … …  
    4140        }
    4241
     42        /**
     43         * @expectedDeprecated get_theme
     44         * @expectedDeprecated get_themes
     45         */
    4346        function test_theme_default() {
    4447                $themes = get_themes();
    … …  
    6871        }
    6972
     73        /**
     74         * @expectedDeprecated get_theme
     75         * @expectedDeprecated get_themes
     76         */
    7077        function test_theme_sandbox() {
    7178                $theme = get_theme('Sandbox');
    … …  
    99106        }
    100107
    101         // a css only theme
     108        /**
     109         * A CSS-only theme
     110         *
     111         * @expectedDeprecated get_themes
     112         */
    102113        function test_theme_stylesheet_only() {
    103114                $themes = get_themes();
    … …  
    127138        }
    128139
     140        /**
     141         * @expectedDeprecated get_themes
     142         */
    129143        function test_theme_list() {
    130144                $themes = get_themes();
    … …  
    154168        }
    155169
     170        /**
     171         * @expectedDeprecated get_themes
     172         * @expectedDeprecated get_broken_themes
     173         */
    156174        function test_broken_themes() {
    157175                $themes = get_themes();
    … …  
    166184        }
    167185
     186        /**
     187         * @expectedDeprecated get_themes
     188         */
    168189        function test_page_templates() {
    169190                $themes = get_themes();
    … …  
    176197        }
    177198
     199        /**
     200         * @expectedDeprecated get_theme_data
     201         */
    178202        function test_get_theme_data_top_level() {
    179203                $theme_data = get_theme_data( DIR_TESTDATA . '/themedir1/theme1/style.css' );
    … …  
    192216        }
    193217
     218        /**
     219         * @expectedDeprecated get_theme_data
     220         */
    194221        function test_get_theme_data_subdir() {
    195222                $theme_data = get_theme_data( $this->theme_root . '/subdir/theme2/style.css' );
  • trunk/tests/phpunit/tests/user.php

    r25390 r25409  
    66 */
    77class Tests_User extends WP_UnitTestCase {
    8 
    9         protected $_deprecated_errors = array();
    10 
    11         function setUp() {
    12                 parent::setUp();
    13                 $this->_deprecated_errors = array();
    14         }
    15 
    16         public function deprecated_handler( $function, $message, $version ) {
    17                 $this->_deprecated_errors[] = array(
    18                         'function' => $function,
    19                         'message'  => $message,
    20                         'version'  => $version
    21                 );
    22         }
    23 
    24         public function disable_deprecated_errors( $value ) {
    25                 return false;
    26         }
    278
    289        function test_get_users_of_blog() {
    … …  
    179160                $this->assertEquals( $user->customField, 123 );
    180161                unset( $user->customField );
    181                 $this->assertFalse( isset( $user->customField ) );
    182 
     162                // $this->assertFalse( isset( $user->customField ) );
     163                return $user;
     164        }
     165
     166        /**
     167         * @depends test_user_unset
     168         * @expectedDeprecated WP_User->id
     169         * @ticket 20043
     170         */
     171        function test_user_unset_lowercase_id( $user ) {
    183172                // Test 'id' (lowercase)
    184                 add_action( 'deprecated_argument_run', array( $this, 'deprecated_handler' ), 10, 3 );
    185                 add_filter( 'deprecated_argument_trigger_error', array( $this, 'disable_deprecated_errors' ) );
    186173                unset( $user->id );
    187                 $this->assertCount( 1, $this->_deprecated_errors );
    188                 $this->assertEquals( 'WP_User->id', $this->_deprecated_errors[0]['function'] );
    189                 $this->assertEquals( '2.1', $this->_deprecated_errors[0]['version'] );
    190                 remove_filter( 'deprecated_argument_trigger_error', array( $this, 'disable_deprecated_errors' ) );
    191                 remove_action( 'deprecated_argument_run', array( $this, 'deprecated_handler' ), 10, 3);
    192 
     174                return $user;
     175        }
     176
     177        /**
     178         * @depends test_user_unset_lowercase_id
     179         * @ticket 20043
     180         */
     181        function test_user_unset_uppercase_id( $user ) {
    193182                // Test 'ID'
    194183                $this->assertNotEmpty( $user->ID );
    … …  
    211200        }
    212201
     202        /**
     203         * @expectedDeprecated WP_User->id
     204         */
    213205        function test_id_property_back_compat() {
    214206                $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
    215207                $user = new WP_User( $user_id );
    216208
    217                 add_filter( 'deprecated_argument_trigger_error', array( $this, 'disable_deprecated_errors' ) );
    218209                $this->assertTrue( isset( $user->id ) );
    219210                $this->assertEquals( $user->ID, $user->id );
    220211                $user->id = 1234;
    221212                $this->assertEquals( $user->ID, $user->id );
    222                 remove_filter( 'deprecated_argument_trigger_error', array( $this, 'disable_deprecated_errors' ) );
    223213        }
    224214
  • trunk/tests/phpunit/tests/user/capabilities.php

    r25402 r25409  
    99class Tests_User_Capabilities extends WP_UnitTestCase {
    1010        protected $user_ids = array();
    11         protected $deprecated_functions = array( 'set_current_user' );
    1211
    1312        function setUp() {
    … …  
    652651                $user = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
    653652                $old_uid = get_current_user_id();
    654                 set_current_user( $user->ID );
     653                wp_set_current_user( $user->ID );
    655654
    656655                $this->assertTrue( current_user_can_for_blog( get_current_blog_id(), 'edit_posts' ) );
    … …  
    667666                $this->assertFalse( current_user_can_for_blog( $blog_id, 'foo_the_bar' ) );
    668667
    669                 set_current_user( $old_uid );
    670         }
    671 
    672         function test_wp_set_current_user() {
    673                 $user = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
    674                 $old_uid = get_current_user_id();
    675                 wp_set_current_user( $user->ID );
    676 
    677                 $this->assertTrue( current_user_can_for_blog( get_current_blog_id(), 'edit_posts' ) );
    678                 $this->assertFalse( current_user_can_for_blog( get_current_blog_id(), 'foo_the_bar' ) );
    679                 if ( ! is_multisite() ) {
    680                         $this->assertTrue( current_user_can_for_blog( 12345, 'edit_posts' ) );
    681                         return;
    682                 }
    683 
    684                 $this->assertFalse( current_user_can_for_blog( 12345, 'edit_posts' ) );
    685 
    686                 $blog_id = $this->factory->blog->create( array( 'user_id' => $user->ID ) );
    687                 $this->assertTrue( current_user_can_for_blog( $blog_id, 'edit_posts' ) );
    688                 $this->assertFalse( current_user_can_for_blog( $blog_id, 'foo_the_bar' ) );
    689 
    690668                wp_set_current_user( $old_uid );
    691669        }
Note: See TracChangeset for help on using the changeset viewer.