Make WordPress Core


Ignore:
Timestamp:
11/29/2021 08:45:31 AM (2 years ago)
Author:
SergeyBiryukov
Message:

Tests: Replace assertEquals() with assertSame() in block template 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(), assertSameSets(), or assertSameSetsWithIndex() should generally be preferred, to make the tests more reliable.

Follow-up to [51003], [51079], [52062], [52265].

See #53364, #53363, #54335.

File:
1 edited

Legend:

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

    r52265 r52266  
    11<?php
    22/**
    3  * Block_Template_Test class
     3 * Tests_Block_Template class
    44 *
    55 * @package WordPress
     
    3737        );
    3838        $resolved_template_path = locate_block_template( get_stylesheet_directory() . '/page-home.php', $type, $templates );
    39         $this->assertEquals( self::$template_canvas_path, $resolved_template_path );
     39        $this->assertSame( self::$template_canvas_path, $resolved_template_path );
    4040        $this->assertStringEqualsFile( get_stylesheet_directory() . '/templates/page-home.html', $_wp_current_template_content );
    4141    }
     
    5050        );
    5151        $resolved_template_path = locate_block_template( get_stylesheet_directory() . '/page.php', $type, $templates );
    52         $this->assertEquals( self::$template_canvas_path, $resolved_template_path );
     52        $this->assertSame( self::$template_canvas_path, $resolved_template_path );
    5353        $this->assertStringEqualsFile( get_stylesheet_directory() . '/templates/page.html', $_wp_current_template_content );
    5454    }
     
    6161        );
    6262        $resolved_template_path = locate_block_template( get_stylesheet_directory() . '/index.php', $type, $templates );
    63         $this->assertEquals( self::$template_canvas_path, $resolved_template_path );
     63        $this->assertSame( self::$template_canvas_path, $resolved_template_path );
    6464        $this->assertStringEqualsFile( get_stylesheet_directory() . '/templates/index.html', $_wp_current_template_content );
    6565    }
     
    8181        );
    8282        $resolved_template_path = locate_block_template( $page_id_template_path, $type, $templates );
    83         $this->assertEquals( $page_id_template_path, $resolved_template_path );
     83        $this->assertSame( $page_id_template_path, $resolved_template_path );
    8484    }
    8585
     
    111111        );
    112112        $resolved_template_path  = locate_block_template( $page_slug_template_path, $type, $templates );
    113         $this->assertEquals( $page_slug_template_path, $resolved_template_path );
     113        $this->assertSame( $page_slug_template_path, $resolved_template_path );
    114114    }
    115115
     
    128128        );
    129129        $resolved_template_path          = locate_block_template( $parent_theme_page_template_path, $type, $templates );
    130         $this->assertEquals( self::$template_canvas_path, $resolved_template_path );
     130        $this->assertSame( self::$template_canvas_path, $resolved_template_path );
    131131        $this->assertStringEqualsFile( get_stylesheet_directory() . '/templates/page-1.html', $_wp_current_template_content );
    132132    }
Note: See TracChangeset for help on using the changeset viewer.