Make WordPress Core


Ignore:
Timestamp:
06/07/2021 11:16:29 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use assertSame() in some newly introduced 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.

Follow-up to [50380], [50959], [50960], [50973], [50993], [51003], [51051], [51054].

See #52482.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/block-template-utils.php

    r51003 r51079  
    4141
    4242        $this->assertNotWPError( $template );
    43         $this->assertEquals( get_stylesheet() . '//my_template', $template->id );
    44         $this->assertEquals( get_stylesheet(), $template->theme );
    45         $this->assertEquals( 'my_template', $template->slug );
    46         $this->assertEquals( 'publish', $template->status );
    47         $this->assertEquals( 'custom', $template->source );
    48         $this->assertEquals( 'My Template', $template->title );
    49         $this->assertEquals( 'Description of my template', $template->description );
    50         $this->assertEquals( 'wp_template', $template->type );
     43        $this->assertSame( get_stylesheet() . '//my_template', $template->id );
     44        $this->assertSame( get_stylesheet(), $template->theme );
     45        $this->assertSame( 'my_template', $template->slug );
     46        $this->assertSame( 'publish', $template->status );
     47        $this->assertSame( 'custom', $template->source );
     48        $this->assertSame( 'My Template', $template->title );
     49        $this->assertSame( 'Description of my template', $template->description );
     50        $this->assertSame( 'wp_template', $template->type );
    5151    }
    5252
     
    5757        $id       = get_stylesheet() . '//' . 'my_template';
    5858        $template = get_block_template( $id, 'wp_template' );
    59         $this->assertEquals( $id, $template->id );
    60         $this->assertEquals( get_stylesheet(), $template->theme );
    61         $this->assertEquals( 'my_template', $template->slug );
    62         $this->assertEquals( 'publish', $template->status );
    63         $this->assertEquals( 'custom', $template->source );
    64         $this->assertEquals( 'wp_template', $template->type );
     59        $this->assertSame( $id, $template->id );
     60        $this->assertSame( get_stylesheet(), $template->theme );
     61        $this->assertSame( 'my_template', $template->slug );
     62        $this->assertSame( 'publish', $template->status );
     63        $this->assertSame( 'custom', $template->source );
     64        $this->assertSame( 'wp_template', $template->type );
    6565    }
    6666
     
    8888        $templates    = get_block_templates( array( 'slug__in' => array( 'my_template' ) ), 'wp_template' );
    8989        $template_ids = get_template_ids( $templates );
    90         $this->assertEquals( array( get_stylesheet() . '//' . 'my_template' ), $template_ids );
     90        $this->assertSame( array( get_stylesheet() . '//' . 'my_template' ), $template_ids );
    9191
    9292        // Filter by CPT ID.
    9393        $templates    = get_block_templates( array( 'wp_id' => self::$post->ID ), 'wp_template' );
    9494        $template_ids = get_template_ids( $templates );
    95         $this->assertEquals( array( get_stylesheet() . '//' . 'my_template' ), $template_ids );
     95        $this->assertSame( array( get_stylesheet() . '//' . 'my_template' ), $template_ids );
    9696    }
    9797}
Note: See TracChangeset for help on using the changeset viewer.