Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Tests: First pass at using assertSame() instead of assertEquals() in most of the unit tests.

This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using assertSame() should generally be preferred to assertEquals() where appropriate, to make the tests more reliable.

Props johnbillion, jrf, SergeyBiryukov.
See #38266.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/multisite/ms-files-rewriting.php

    r46586 r48937  
    4141            $blog_id2 = self::factory()->blog->create( array( 'user_id' => $user_id ) );
    4242            $info     = wp_upload_dir();
    43             $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['url'] );
    44             $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['path'] );
    45             $this->assertEquals( gmstrftime( '/%Y/%m' ), $info['subdir'] );
    46             $this->assertEquals( '', $info['error'] );
     43            $this->assertSame( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['url'] );
     44            $this->assertSame( ABSPATH . 'wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['path'] );
     45            $this->assertSame( gmstrftime( '/%Y/%m' ), $info['subdir'] );
     46            $this->assertFalse( $info['error'] );
    4747
    4848            switch_to_blog( $blog_id2 );
    4949            $info2 = wp_upload_dir();
    5050            $this->assertNotEquals( $info, $info2 );
    51             $this->assertEquals( get_option( 'siteurl' ) . '/wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime( '%Y/%m' ), $info2['url'] );
    52             $this->assertEquals( ABSPATH . 'wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime( '%Y/%m' ), $info2['path'] );
    53             $this->assertEquals( gmstrftime( '/%Y/%m' ), $info2['subdir'] );
    54             $this->assertEquals( '', $info2['error'] );
     51            $this->assertSame( get_option( 'siteurl' ) . '/wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime( '%Y/%m' ), $info2['url'] );
     52            $this->assertSame( ABSPATH . 'wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime( '%Y/%m' ), $info2['path'] );
     53            $this->assertSame( gmstrftime( '/%Y/%m' ), $info2['subdir'] );
     54            $this->assertFalse( $info2['error'] );
    5555            restore_current_blog();
    5656        }
Note: See TracChangeset for help on using the changeset viewer.