Make WordPress Core


Ignore:
Timestamp:
10/07/2022 01:02:07 AM (3 years ago)
Author:
desrosj
Message:

Tests: Replace some occurrences of assertEquals() with assertSame().

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

Props costdev, desrosj.
See #55654.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/customize/selective-refresh-ajax.php

    r52010 r54402  
    189189        );
    190190
    191         $count_customize_render_partials_before = has_action( 'customize_render_partials_before' );
    192         $count_customize_render_partials_after  = has_action( 'customize_render_partials_after' );
    193191        ob_start();
    194192        try {
     
    201199            $this->assertSame( '', $e->getMessage() );
    202200        }
    203         $this->assertEquals( $count_customize_render_partials_before + 1, has_action( 'customize_render_partials_before' ) );
    204         $this->assertEquals( $count_customize_render_partials_after + 1, has_action( 'customize_render_partials_after' ) );
     201        $this->assertTrue( has_action( 'customize_render_partials_before' ) );
     202        $this->assertTrue( has_action( 'customize_render_partials_after' ) );
    205203        $output = json_decode( ob_get_clean(), true );
    206204        $this->assertSame( array( false ), $output['data']['contents']['foo'] );
     
    327325        );
    328326
    329         $count_customize_render_partials_before = has_action( 'customize_render_partials_before' );
    330         $count_customize_render_partials_after  = has_action( 'customize_render_partials_after' );
    331327        ob_start();
    332328        try {
     
    339335            $this->assertSame( '', $e->getMessage() );
    340336        }
    341         $this->assertEquals( $count_customize_render_partials_before + 1, has_action( 'customize_render_partials_before' ) );
    342         $this->assertEquals( $count_customize_render_partials_after + 1, has_action( 'customize_render_partials_after' ) );
     337        $this->assertTrue( has_action( 'customize_render_partials_before' ) );
     338        $this->assertTrue( has_action( 'customize_render_partials_after' ) );
    343339        $output = json_decode( ob_get_clean(), true );
    344340        $this->assertSame( array( get_bloginfo( 'name', 'display' ) ), $output['data']['contents']['test_blogname'] );
     
    436432        );
    437433
    438         $count_customize_render_partials_before = has_action( 'customize_render_partials_before' );
    439         $count_customize_render_partials_after  = has_action( 'customize_render_partials_after' );
    440434        ob_start();
    441435        try {
     
    448442            $this->assertSame( '', $e->getMessage() );
    449443        }
    450         $this->assertEquals( $count_customize_render_partials_before + 1, has_action( 'customize_render_partials_before' ) );
    451         $this->assertEquals( $count_customize_render_partials_after + 1, has_action( 'customize_render_partials_after' ) );
     444        $this->assertTrue( has_action( 'customize_render_partials_before' ) );
     445        $this->assertTrue( has_action( 'customize_render_partials_after' ) );
    452446        $output = json_decode( ob_get_clean(), true );
    453447        $this->assertSame( array( get_bloginfo( 'name', 'display' ) ), $output['data']['contents']['test_dynamic_blogname'] );
     
    488482        );
    489483
    490         $count_customize_render_partials_before = has_action( 'customize_render_partials_before' );
    491         $count_customize_render_partials_after  = has_action( 'customize_render_partials_after' );
    492484        ob_start();
    493485        try {
     
    500492            $this->assertSame( '', $e->getMessage() );
    501493        }
    502         $this->assertEquals( $count_customize_render_partials_before + 1, has_action( 'customize_render_partials_before' ) );
    503         $this->assertEquals( $count_customize_render_partials_after + 1, has_action( 'customize_render_partials_after' ) );
     494        $this->assertTrue( has_action( 'customize_render_partials_before' ) );
     495        $this->assertTrue( has_action( 'customize_render_partials_after' ) );
    504496        $output = json_decode( ob_get_clean(), true );
    505497        $this->assertSame( array( get_bloginfo( 'name', 'display' ) ), $output['data']['contents']['test_blogname'] );
Note: See TracChangeset for help on using the changeset viewer.