Make WordPress Core


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.