Make WordPress Core


Ignore:
Timestamp:
10/17/2015 07:24:20 PM (9 years ago)
Author:
wonderboymusic
Message:

Unit Tests: WP_UnitTest_Generator_Sequence needs a static incrementer - otherwise, it assumes every test class is a reset, which it no longer is (it is now static).

While we're at it, remove unnecessary tearDown() code.

See #30017, #33968.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/user.php

    r35242 r35244  
    245245
    246246        foreach ( $roles as $role => $level ) {
    247             $user_id = self::factory()->user->create( array( 'role' => $role ) );
     247            $user_id = self::factory()->user->create( array(
     248                'user_email' => 'user_19265_' . $role . '@burritos.com',
     249                'user_login' => 'user_19265_' . $role,
     250                'role' => $role
     251            ) );
    248252            $user = new WP_User( $user_id );
    249253
     
    776780        ) );
    777781
     782        $user1 = new WP_User( $u1 );
     783
     784        $expected = str_repeat( 'a', 50 );
     785        $this->assertSame( $expected, $user1->user_nicename );
     786
    778787        $user_login = str_repeat( 'a', 55 );
    779788        $u = wp_insert_user( array(
     
    784793
    785794        $this->assertNotEmpty( $u );
    786         $user = new WP_User( $u );
     795        $user2 = new WP_User( $u );
    787796        $expected = str_repeat( 'a', 48 ) . '-2';
    788         $this->assertSame( $expected, $user->user_nicename );
     797        $this->assertSame( $expected, $user2->user_nicename );
    789798    }
    790799
     
    793802     */
    794803    public function test_wp_insert_user_should_not_truncate_to_a_duplicate_user_nicename_when_suffix_has_more_than_one_character() {
    795         $users = self::factory()->user->create_many( 4, array(
     804        $user_ids = self::factory()->user->create_many( 4, array(
    796805            'user_nicename' => str_repeat( 'a', 50 ),
    797806        ) );
     807
     808        foreach ( $user_ids as $i => $user_id ) {
     809            $user = new WP_User( $user_id );
     810            if ( 0 === $i ) {
     811                $expected = str_repeat( 'a', 50 );
     812            } else {
     813                $expected = str_repeat( 'a', 48 ) . '-' . ( $i + 1 );
     814            }
     815            $this->assertSame( $expected, $user->user_nicename );
     816        }
    798817
    799818        $user_login = str_repeat( 'a', 55 );
Note: See TracChangeset for help on using the changeset viewer.