Make WordPress Core

Changeset 64804


Ignore:
Timestamp:
10/27/2026 05:48:06 PM (3 days ago)
Author:
lancewillett
Message:

Tests: Use strict inequality in Customizer tests.

Use assertNotSame() for scalar and array comparisons in Customizer tests, including menu item counts, changeset data, and sidebar parameters.

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/14975

Props shailu25.
See #64895.

Location:
trunk/tests/phpunit/tests/customize
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/customize/manager.php

    r64657 r64804  
    422422                $title        = 'Hello World';
    423423                $wp_customize->set_post_value( 'blogname', $title );
    424                 $this->assertNotEquals( $title, get_option( 'blogname' ) );
     424                $this->assertNotSame( $title, get_option( 'blogname' ) );
    425425                $wp_customize->wp_loaded();
    426426                $this->assertFalse( $wp_customize->is_preview() );
    … …  
    451451
    452452                // Verify that the found post ID was cached under the given UUID, not the manager's UUID.
    453                 $this->assertNotEquals( $post_id, $wp_customize->find_changeset_post_id( $wp_customize->changeset_uuid() ) );
     453                $this->assertNotSame( $post_id, $wp_customize->find_changeset_post_id( $wp_customize->changeset_uuid() ) );
    454454        }
    455455
    … …  
    535535                );
    536536                $this->assertTrue( $wp_customize->autosaved() );
    537                 $this->assertNotEquals( $data, $wp_customize->changeset_data() );
     537                $this->assertNotSame( $data, $wp_customize->changeset_data() );
    538538                $this->assertSame(
    539539                        array_merge(
    … …  
    801801                $this->assertSame( $previous_blogname, $changeset_data['blogname']['value'] );
    802802                $this->assertArrayNotHasKey( 'starter_content', $changeset_data['blogname'] );
    803                 $this->assertNotEquals( $previous_blogdescription, $changeset_data['blogdescription']['value'] );
     803                $this->assertNotSame( $previous_blogdescription, $changeset_data['blogdescription']['value'] );
    804804                $this->assertArrayHasKey( 'starter_content', $changeset_data['blogdescription'] );
    805805
    … …  
    813813                $this->assertSame( 'auto-draft', get_post( $posts_by_name['about'] )->post_status );
    814814                $this->assertSame( 'auto-draft', get_post( $posts_by_name['waffles'] )->post_status );
    815                 $this->assertNotEquals( $changeset_data['blogname']['value'], get_option( 'blogname' ) );
     815                $this->assertNotSame( $changeset_data['blogname']['value'], get_option( 'blogname' ) );
    816816                $r = $wp_customize->save_changeset_post( array( 'status' => 'publish' ) );
    817817                $this->assertIsArray( $r );
    … …  
    10881088                $this->assertSame( 'auto-draft', get_post( $post_id )->post_status );
    10891089                $this->assertSame( $date, get_post( $post_id )->post_date_gmt );
    1090                 $this->assertNotEquals( 'Changeset Title', get_option( 'blogname' ) );
     1090                $this->assertNotSame( 'Changeset Title', get_option( 'blogname' ) );
    10911091                $this->assertArrayHasKey( 'setting_validities', $r );
    10921092
    … …  
    11701170                $this->assertWPError( $r['setting_validities']['bar_unknown'] );
    11711171                $saved_data = json_decode( get_post( $post_id )->post_content, true );
    1172                 $this->assertNotEquals( $previous_saved_data, $saved_data );
     1172                $this->assertNotSame( $previous_saved_data, $saved_data );
    11731173                $this->assertSame( 'Non-Transactional \o/ <script>unsanitized</script>', $saved_data['blogname']['value'] );
    11741174
    … …  
    17221722
    17231723                $post = get_post( $changeset_post_id );
    1724                 $this->assertNotEquals( $post->post_date, $original_post_date );
     1724                $this->assertNotSame( $post->post_date, $original_post_date );
    17251725        }
    17261726
  • trunk/tests/phpunit/tests/customize/nav-menu-item-setting.php

    r64654 r64804  
    457457                $setting->preview();
    458458                $preview_items = wp_get_nav_menu_items( $menu_id );
    459                 $this->assertNotEquals( count( $current_items ), count( $preview_items ) );
     459                $this->assertNotSame( count( $current_items ), count( $preview_items ) );
    460460
    461461                $last_item = array_pop( $preview_items );
    … …  
    506506                $setting->preview();
    507507                $preview_items = wp_get_nav_menu_items( $menu_id );
    508                 $this->assertNotEquals( count( $current_items ), count( $preview_items ) );
     508                $this->assertNotSame( count( $current_items ), count( $preview_items ) );
    509509                $this->assertContains( $delete_item_id, wp_list_pluck( $current_items, 'db_id' ) );
    510510        }
    … …  
    767767                $setting->save();
    768768                $preview_items = wp_get_nav_menu_items( $menu_id );
    769                 $this->assertNotEquals( count( $current_items ), count( $preview_items ) );
     769                $this->assertNotSame( count( $current_items ), count( $preview_items ) );
    770770
    771771                $last_item = array_pop( $preview_items );
    … …  
    833833                $setting->save();
    834834                $preview_items = wp_get_nav_menu_items( $menu_id );
    835                 $this->assertNotEquals( count( $current_items ), count( $preview_items ) );
     835                $this->assertNotSame( count( $current_items ), count( $preview_items ) );
    836836                $this->assertContains( $delete_item_id, wp_list_pluck( $current_items, 'db_id' ) );
    837837
  • trunk/tests/phpunit/tests/customize/setting.php

    r64649 r64804  
    602602                switch_to_blog( $blog_id );
    603603                $this->assertFalse( $setting->is_current_blog_previewed() );
    604                 $this->assertNotEquals( $post_value, $setting->value() );
    605                 $this->assertNotEquals( $post_value, get_option( $name ) );
     604                $this->assertNotSame( $post_value, $setting->value() );
     605                $this->assertNotSame( $post_value, get_option( $name ) );
    606606                restore_current_blog();
    607607        }
  • trunk/tests/phpunit/tests/customize/widgets.php

    r64061 r64804  
    834834
    835835                $filtered_params = $this->manager->widgets->filter_dynamic_sidebar_params( $params );
    836                 $this->assertNotEquals( $params, $filtered_params );
     836                $this->assertNotSame( $params, $filtered_params );
    837837                ob_start();
    838838                do_action( 'dynamic_sidebar_after', 'foo' );
Note: See TracChangeset for help on using the changeset viewer.