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/customize/setting.php

    r47198 r48937  
    3434    function test_constructor_without_args() {
    3535        $setting = new WP_Customize_Setting( $this->manager, 'foo' );
    36         $this->assertEquals( $this->manager, $setting->manager );
    37         $this->assertEquals( 'foo', $setting->id );
    38         $this->assertEquals( 'theme_mod', $setting->type );
    39         $this->assertEquals( 'edit_theme_options', $setting->capability );
    40         $this->assertEquals( '', $setting->theme_supports );
    41         $this->assertEquals( '', $setting->default );
    42         $this->assertEquals( 'refresh', $setting->transport );
    43         $this->assertEquals( '', $setting->sanitize_callback );
    44         $this->assertEquals( '', $setting->sanitize_js_callback );
     36        $this->assertSame( $this->manager, $setting->manager );
     37        $this->assertSame( 'foo', $setting->id );
     38        $this->assertSame( 'theme_mod', $setting->type );
     39        $this->assertSame( 'edit_theme_options', $setting->capability );
     40        $this->assertSame( '', $setting->theme_supports );
     41        $this->assertSame( '', $setting->default );
     42        $this->assertSame( 'refresh', $setting->transport );
     43        $this->assertSame( '', $setting->sanitize_callback );
     44        $this->assertSame( '', $setting->sanitize_js_callback );
    4545        $this->assertFalse( has_filter( "customize_validate_{$setting->id}" ) );
    4646        $this->assertFalse( has_filter( "customize_sanitize_{$setting->id}" ) );
    4747        $this->assertFalse( has_filter( "customize_sanitize_js_{$setting->id}" ) );
    48         $this->assertEquals( false, $setting->dirty );
     48        $this->assertFalse( $setting->dirty );
    4949    }
    5050
     
    101101        );
    102102        $setting = new WP_Customize_Setting( $this->manager, 'bar', $args );
    103         $this->assertEquals( 'bar', $setting->id );
     103        $this->assertSame( 'bar', $setting->id );
    104104        foreach ( $args as $key => $value ) {
    105             $this->assertEquals( $value, $setting->$key );
     105            $this->assertSame( $value, $setting->$key );
    106106        }
    107         $this->assertEquals( 10, has_filter( "customize_validate_{$setting->id}", $args['validate_callback'] ) );
    108         $this->assertEquals( 10, has_filter( "customize_sanitize_{$setting->id}", $args['sanitize_callback'] ) );
    109         $this->assertEquals( 10, has_filter( "customize_sanitize_js_{$setting->id}", $args['sanitize_js_callback'] ) );
     107        $this->assertSame( 10, has_filter( "customize_validate_{$setting->id}", $args['validate_callback'] ) );
     108        $this->assertSame( 10, has_filter( "customize_sanitize_{$setting->id}", $args['sanitize_callback'] ) );
     109        $this->assertSame( 10, has_filter( "customize_sanitize_js_{$setting->id}", $args['sanitize_js_callback'] ) );
    110110    }
    111111
     
    147147            $default = "default_value_{$name}";
    148148            $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
    149             $this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $name, $this->undefined ) );
    150             $this->assertEquals( $default, $setting->value() );
     149            $this->assertSame( $this->undefined, call_user_func( $type_options['getter'], $name, $this->undefined ) );
     150            $this->assertSame( $default, $setting->value() );
    151151            $this->assertTrue( $setting->preview(), 'Preview should not no-op since setting has no existing value.' );
    152             $this->assertEquals( $default, call_user_func( $type_options['getter'], $name, $this->undefined ), sprintf( 'Expected %s(%s) to return setting default: %s.', $type_options['getter'], $name, $default ) );
    153             $this->assertEquals( $default, $setting->value() );
     152            $this->assertSame( $default, call_user_func( $type_options['getter'], $name, $this->undefined ), sprintf( 'Expected %s(%s) to return setting default: %s.', $type_options['getter'], $name, $default ) );
     153            $this->assertSame( $default, $setting->value() );
    154154
    155155            // Non-multidimensional: See what effect the preview has on an extant setting (default value should not be seen).
     
    159159            call_user_func( $type_options['setter'], $name, $initial_value );
    160160            $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
    161             $this->assertEquals( $initial_value, call_user_func( $type_options['getter'], $name ) );
    162             $this->assertEquals( $initial_value, $setting->value() );
     161            $this->assertSame( $initial_value, call_user_func( $type_options['getter'], $name ) );
     162            $this->assertSame( $initial_value, $setting->value() );
    163163            $this->assertFalse( $setting->preview(), 'Preview should no-op since setting value was extant and no post value was present.' );
    164             $this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
    165             $this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
    166             $this->assertEquals( $initial_value, call_user_func( $type_options['getter'], $name ) );
    167             $this->assertEquals( $initial_value, $setting->value() );
     164            $this->assertSame( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
     165            $this->assertSame( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
     166            $this->assertSame( $initial_value, call_user_func( $type_options['getter'], $name ) );
     167            $this->assertSame( $initial_value, $setting->value() );
    168168
    169169            // Non-multidimensional: Try updating a value that had a no-op preview.
     
    171171            call_user_func( $type_options['setter'], $name, $overridden_value );
    172172            $message = 'Initial value should be overridden because initial preview() was no-op due to setting having existing value and/or post value was absent.';
    173             $this->assertEquals( $overridden_value, call_user_func( $type_options['getter'], $name ), $message );
    174             $this->assertEquals( $overridden_value, $setting->value(), $message );
     173            $this->assertSame( $overridden_value, call_user_func( $type_options['getter'], $name ), $message );
     174            $this->assertSame( $overridden_value, $setting->value(), $message );
    175175            $this->assertNotEquals( $initial_value, $setting->value(), $message );
    176176
    177177            // Non-multidimensional: Ensure that setting a post value *after* preview() is called results in the post value being seen (deferred preview).
    178178            $post_value = "post_value_for_{$setting->id}_set_after_preview_called";
    179             $this->assertEquals( 0, did_action( "customize_post_value_set_{$setting->id}" ) );
     179            $this->assertSame( 0, did_action( "customize_post_value_set_{$setting->id}" ) );
    180180            $this->manager->set_post_value( $setting->id, $post_value );
    181             $this->assertEquals( 1, did_action( "customize_post_value_set_{$setting->id}" ) );
     181            $this->assertSame( 1, did_action( "customize_post_value_set_{$setting->id}" ) );
    182182            $this->assertNotEquals( $overridden_value, $setting->value() );
    183             $this->assertEquals( $post_value, call_user_func( $type_options['getter'], $name ) );
    184             $this->assertEquals( $post_value, $setting->value() );
     183            $this->assertSame( $post_value, call_user_func( $type_options['getter'], $name ) );
     184            $this->assertSame( $post_value, $setting->value() );
    185185
    186186            // Non-multidimensional: Test unset setting being overridden by a post value.
     
    188188            $default = "default_value_{$name}";
    189189            $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
    190             $this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $name, $this->undefined ) );
    191             $this->assertEquals( $default, $setting->value() );
     190            $this->assertSame( $this->undefined, call_user_func( $type_options['getter'], $name, $this->undefined ) );
     191            $this->assertSame( $default, $setting->value() );
    192192            $this->assertTrue( $setting->preview(), 'Preview applies because setting has post_data_overrides.' ); // Activate post_data.
    193             $this->assertEquals( $this->post_data_overrides[ $name ], call_user_func( $type_options['getter'], $name, $this->undefined ) );
    194             $this->assertEquals( $this->post_data_overrides[ $name ], $setting->value() );
     193            $this->assertSame( $this->post_data_overrides[ $name ], call_user_func( $type_options['getter'], $name, $this->undefined ) );
     194            $this->assertSame( $this->post_data_overrides[ $name ], $setting->value() );
    195195
    196196            // Non-multidimensional: Test set setting being overridden by a post value.
     
    200200            call_user_func( $type_options['setter'], $name, $initial_value );
    201201            $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
    202             $this->assertEquals( $initial_value, call_user_func( $type_options['getter'], $name, $this->undefined ) );
    203             $this->assertEquals( $initial_value, $setting->value() );
     202            $this->assertSame( $initial_value, call_user_func( $type_options['getter'], $name, $this->undefined ) );
     203            $this->assertSame( $initial_value, $setting->value() );
    204204            $this->assertTrue( $setting->preview(), 'Preview applies because setting has post_data_overrides.' ); // Activate post_data.
    205             $this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
    206             $this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
    207             $this->assertEquals( $this->post_data_overrides[ $name ], call_user_func( $type_options['getter'], $name, $this->undefined ) );
    208             $this->assertEquals( $this->post_data_overrides[ $name ], $setting->value() );
     205            $this->assertSame( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
     206            $this->assertSame( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
     207            $this->assertSame( $this->post_data_overrides[ $name ], call_user_func( $type_options['getter'], $name, $this->undefined ) );
     208            $this->assertSame( $this->post_data_overrides[ $name ], $setting->value() );
    209209        }
    210210    }
     
    226226            $default   = "default_value_{$name}";
    227227            $setting   = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
    228             $this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $base_name, $this->undefined ) );
    229             $this->assertEquals( $default, $setting->value() );
     228            $this->assertSame( $this->undefined, call_user_func( $type_options['getter'], $base_name, $this->undefined ) );
     229            $this->assertSame( $default, $setting->value() );
    230230            $this->assertTrue( $setting->preview(), "Preview for $setting->id should apply because setting is not in DB." );
    231231            $base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined );
    232232            $this->assertArrayHasKey( 'foo', $base_value );
    233             $this->assertEquals( $default, $base_value['foo'] );
     233            $this->assertSame( $default, $base_value['foo'] );
    234234
    235235            // Multidimensional: See what effect the preview has on an extant setting (default value should not be seen) without post value.
     
    245245            $setting    = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
    246246            $base_value = call_user_func( $type_options['getter'], $base_name, array() );
    247             $this->assertEquals( $initial_value, $base_value['foo'] );
    248             $this->assertEquals( $initial_value, $setting->value() );
     247            $this->assertSame( $initial_value, $base_value['foo'] );
     248            $this->assertSame( $initial_value, $setting->value() );
    249249            $this->assertFalse( $setting->preview(), "Preview for $setting->id should no-op because setting is in DB and post value is absent." );
    250             $this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
    251             $this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
     250            $this->assertSame( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
     251            $this->assertSame( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
    252252            $base_value = call_user_func( $type_options['getter'], $base_name, array() );
    253             $this->assertEquals( $initial_value, $base_value['foo'] );
    254             $this->assertEquals( $initial_value, $setting->value() );
     253            $this->assertSame( $initial_value, $base_value['foo'] );
     254            $this->assertSame( $initial_value, $setting->value() );
    255255
    256256            // Multidimensional: Ensure that setting a post value *after* preview() is called results in the post value being seen (deferred preview).
     
    258258            $this->manager->set_post_value( $setting->id, $override_value );
    259259            $base_value = call_user_func( $type_options['getter'], $base_name, array() );
    260             $this->assertEquals( $override_value, $base_value['foo'] );
    261             $this->assertEquals( $override_value, $setting->value() );
     260            $this->assertSame( $override_value, $base_value['foo'] );
     261            $this->assertSame( $override_value, $setting->value() );
    262262
    263263            // Multidimensional: Test unset setting being overridden by a post value.
     
    266266            $default   = "default_value_{$name}";
    267267            $setting   = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
    268             $this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $base_name, $this->undefined ) );
    269             $this->assertEquals( $default, $setting->value() );
     268            $this->assertSame( $this->undefined, call_user_func( $type_options['getter'], $base_name, $this->undefined ) );
     269            $this->assertSame( $default, $setting->value() );
    270270            $this->assertTrue( $setting->preview(), "Preview for $setting->id should apply because a post value is present." );
    271             $this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
    272             $this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
     271            $this->assertSame( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
     272            $this->assertSame( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
    273273            $base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined );
    274274            $this->assertArrayHasKey( 'foo', $base_value );
    275             $this->assertEquals( $this->post_data_overrides[ $name ], $base_value['foo'] );
     275            $this->assertSame( $this->post_data_overrides[ $name ], $base_value['foo'] );
    276276
    277277            // Multidimensional: Test set setting being overridden by a post value.
     
    289289            $this->assertArrayHasKey( 'foo', $base_value );
    290290            $this->assertArrayHasKey( 'bar', $base_value );
    291             $this->assertEquals( $base_initial_value['foo'], $base_value['foo'] );
     291            $this->assertSame( $base_initial_value['foo'], $base_value['foo'] );
    292292
    293293            $getter = call_user_func( $type_options['getter'], $base_name, $this->undefined );
    294             $this->assertEquals( $base_initial_value['bar'], $getter['bar'] );
    295             $this->assertEquals( $initial_value, $setting->value() );
     294            $this->assertSame( $base_initial_value['bar'], $getter['bar'] );
     295            $this->assertSame( $initial_value, $setting->value() );
    296296            $this->assertTrue( $setting->preview(), "Preview for $setting->id should apply because post value is present." );
    297             $this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
    298             $this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
     297            $this->assertSame( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
     298            $this->assertSame( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
    299299            $base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined );
    300300            $this->assertArrayHasKey( 'foo', $base_value );
    301             $this->assertEquals( $this->post_data_overrides[ $name ], $base_value['foo'] );
     301            $this->assertSame( $this->post_data_overrides[ $name ], $base_value['foo'] );
    302302            $this->assertArrayHasKey( 'bar', call_user_func( $type_options['getter'], $base_name, $this->undefined ) );
    303303
    304304            $getter = call_user_func( $type_options['getter'], $base_name, $this->undefined );
    305             $this->assertEquals( $base_initial_value['bar'], $getter['bar'] );
     305            $this->assertSame( $base_initial_value['bar'], $getter['bar'] );
    306306        }
    307307    }
     
    344344        $this->assertInstanceOf( 'WP_Customize_Setting', $setting );
    345345        $id_data = $setting->id_data();
    346         $this->assertEquals( $name, $id_data['base'] );
     346        $this->assertSame( $name, $id_data['base'] );
    347347        return $this->custom_type_getter( $name, $default );
    348348    }
     
    382382        // Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need.
    383383        add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ), 10, 2 );
    384         $this->assertEquals( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) );
    385         $this->assertEquals( $default, $setting->value() );
     384        $this->assertSame( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) );
     385        $this->assertSame( $default, $setting->value() );
    386386        $this->assertTrue( $setting->preview() );
    387         $this->assertEquals( 1, did_action( "customize_preview_{$setting->id}" ) );
    388         $this->assertEquals( 1, did_action( "customize_preview_{$setting->type}" ) );
    389         $this->assertEquals( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) ); // Note: for a non-custom type this is $default.
    390         $this->assertEquals( $default, $setting->value() ); // Should be same as above.
     387        $this->assertSame( 1, did_action( "customize_preview_{$setting->id}" ) );
     388        $this->assertSame( 1, did_action( "customize_preview_{$setting->type}" ) );
     389        $this->assertSame( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) ); // Note: for a non-custom type this is $default.
     390        $this->assertSame( $default, $setting->value() ); // Should be same as above.
    391391
    392392        // Custom type existing and no post value override.
     
    398398        // Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need.
    399399        add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ), 10, 2 );
    400         $this->assertEquals( $initial_value, $this->custom_type_getter( $name, $this->undefined ) );
    401         $this->assertEquals( $initial_value, $setting->value() );
     400        $this->assertSame( $initial_value, $this->custom_type_getter( $name, $this->undefined ) );
     401        $this->assertSame( $initial_value, $setting->value() );
    402402        $this->assertFalse( $setting->preview(), "Preview for $setting->id should not apply because existing type without an override." );
    403         $this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ), 'Zero preview actions because initial value is set with no incoming post value, so there is no preview to apply.' );
    404         $this->assertEquals( 1, did_action( "customize_preview_{$setting->type}" ) );
    405         $this->assertEquals( $initial_value, $this->custom_type_getter( $name, $this->undefined ) ); // Should be same as above.
    406         $this->assertEquals( $initial_value, $setting->value() ); // Should be same as above.
     403        $this->assertSame( 0, did_action( "customize_preview_{$setting->id}" ), 'Zero preview actions because initial value is set with no incoming post value, so there is no preview to apply.' );
     404        $this->assertSame( 1, did_action( "customize_preview_{$setting->type}" ) );
     405        $this->assertSame( $initial_value, $this->custom_type_getter( $name, $this->undefined ) ); // Should be same as above.
     406        $this->assertSame( $initial_value, $setting->value() ); // Should be same as above.
    407407
    408408        // Custom type deferred preview (setting post value after preview ran).
    409409        $override_value = "custom_type_value_{$name}_override_deferred_preview";
    410410        $this->manager->set_post_value( $setting->id, $override_value );
    411         $this->assertEquals( $override_value, $this->custom_type_getter( $name, $this->undefined ) ); // Should be same as above.
    412         $this->assertEquals( $override_value, $setting->value() ); // Should be same as above.
     411        $this->assertSame( $override_value, $this->custom_type_getter( $name, $this->undefined ) ); // Should be same as above.
     412        $this->assertSame( $override_value, $setting->value() ); // Should be same as above.
    413413
    414414        // Custom type not existing and with a post value override.
     
    418418        // Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need.
    419419        add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ), 10, 2 );
    420         $this->assertEquals( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) );
    421         $this->assertEquals( $default, $setting->value() );
     420        $this->assertSame( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) );
     421        $this->assertSame( $default, $setting->value() );
    422422        $this->assertTrue( $setting->preview() );
    423         $this->assertEquals( 1, did_action( "customize_preview_{$setting->id}" ), 'One preview action now because initial value was not set and/or there is no incoming post value, so there is is a preview to apply.' );
    424         $this->assertEquals( 3, did_action( "customize_preview_{$setting->type}" ) );
    425         $this->assertEquals( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) );
    426         $this->assertEquals( $post_data_overrides[ $name ], $setting->value() );
     423        $this->assertSame( 1, did_action( "customize_preview_{$setting->id}" ), 'One preview action now because initial value was not set and/or there is no incoming post value, so there is is a preview to apply.' );
     424        $this->assertSame( 3, did_action( "customize_preview_{$setting->type}" ) );
     425        $this->assertSame( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) );
     426        $this->assertSame( $post_data_overrides[ $name ], $setting->value() );
    427427
    428428        // Custom type not existing and with a post value override.
     
    434434        // Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need.
    435435        add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ), 10, 2 );
    436         $this->assertEquals( $initial_value, $this->custom_type_getter( $name, $this->undefined ) );
    437         $this->assertEquals( $initial_value, $setting->value() );
     436        $this->assertSame( $initial_value, $this->custom_type_getter( $name, $this->undefined ) );
     437        $this->assertSame( $initial_value, $setting->value() );
    438438        $this->assertTrue( $setting->preview() );
    439         $this->assertEquals( 1, did_action( "customize_preview_{$setting->id}" ) );
    440         $this->assertEquals( 4, did_action( "customize_preview_{$setting->type}" ) );
    441         $this->assertEquals( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) );
    442         $this->assertEquals( $post_data_overrides[ $name ], $setting->value() );
     439        $this->assertSame( 1, did_action( "customize_preview_{$setting->id}" ) );
     440        $this->assertSame( 4, did_action( "customize_preview_{$setting->type}" ) );
     441        $this->assertSame( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) );
     442        $this->assertSame( $post_data_overrides[ $name ], $setting->value() );
    443443
    444444        // Custom type that does not handle supplying the post value from the customize_value_{$id_base} filter.
     
    479479        $default = "default_value_{$name}";
    480480        $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
    481         $this->assertEquals( $this->undefined, get_option( $name, $this->undefined ) );
    482         $this->assertEquals( $default, $setting->value() );
     481        $this->assertSame( $this->undefined, get_option( $name, $this->undefined ) );
     482        $this->assertSame( $default, $setting->value() );
    483483        $this->assertTrue( $setting->preview() );
    484         $this->assertEquals( $default, get_option( $name, $this->undefined ), sprintf( 'Expected get_option(%s) to return setting default: %s.', $name, $default ) );
    485         $this->assertEquals( $default, $setting->value() );
     484        $this->assertSame( $default, get_option( $name, $this->undefined ), sprintf( 'Expected get_option(%s) to return setting default: %s.', $name, $default ) );
     485        $this->assertSame( $default, $setting->value() );
    486486    }
    487487
     
    528528     */
    529529    function handle_customize_update_custom_foo_action( $value, $setting = null ) {
    530         $this->assertEquals( 'hello world \\o/', $value );
     530        $this->assertSame( 'hello world \\o/', $value );
    531531        $this->assertInstanceOf( 'WP_Customize_Setting', $setting );
    532532    }
     
    540540    function handle_customize_save_custom_foo_action( $setting ) {
    541541        $this->assertInstanceOf( 'WP_Customize_Setting', $setting );
    542         $this->assertEquals( 'custom', $setting->type );
    543         $this->assertEquals( 'foo', $setting->id );
     542        $this->assertSame( 'custom', $setting->type );
     543        $this->assertSame( 'foo', $setting->id );
    544544    }
    545545
     
    562562        $this->assertTrue( $setting->is_current_blog_previewed() );
    563563
    564         $this->assertEquals( $post_value, $setting->value() );
    565         $this->assertEquals( $post_value, get_option( $name ) );
     564        $this->assertSame( $post_value, $setting->value() );
     565        $this->assertSame( $post_value, get_option( $name ) );
    566566    }
    567567
     
    611611        $setting->save();
    612612        $autoload = $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $setting->id ) );
    613         $this->assertEquals( 'yes', $autoload );
    614         $this->assertEquals( $value, get_option( $name ) );
     613        $this->assertSame( 'yes', $autoload );
     614        $this->assertSame( $value, get_option( $name ) );
    615615
    616616        $name    = 'autoloaded2';
     
    627627        $setting->save();
    628628        $autoload = $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $setting->id ) );
    629         $this->assertEquals( 'yes', $autoload );
    630         $this->assertEquals( $value, get_option( $name ) );
     629        $this->assertSame( 'yes', $autoload );
     630        $this->assertSame( $value, get_option( $name ) );
    631631
    632632        $name    = 'not-autoloaded1';
     
    643643        $setting->save();
    644644        $autoload = $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $setting->id ) );
    645         $this->assertEquals( 'no', $autoload );
    646         $this->assertEquals( $value, get_option( $name ) );
     645        $this->assertSame( 'no', $autoload );
     646        $this->assertSame( $value, get_option( $name ) );
    647647
    648648        $id_base  = 'multi-not-autoloaded';
     
    666666        $setting1->save();
    667667        $autoload = $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $id_base ) );
    668         $this->assertEquals( 'no', $autoload, 'Even though setting1 did not indicate autoload (thus normally true), since another multidimensional option setting of the base did say autoload=false, it should be autoload=no' );
     668        $this->assertSame( 'no', $autoload, 'Even though setting1 did not indicate autoload (thus normally true), since another multidimensional option setting of the base did say autoload=false, it should be autoload=no' );
    669669    }
    670670
     
    686686        $setting = new WP_Customize_Setting( $this->manager, 'name', $args );
    687687
    688         $this->assertEquals( $default, $setting->value() );
    689         $this->assertEquals( base64_encode( $default ), $setting->js_value() );
     688        $this->assertSame( $default, $setting->value() );
     689        $this->assertSame( base64_encode( $default ), $setting->js_value() );
    690690
    691691        $exported = $setting->json();
     
    694694        $this->assertArrayHasKey( 'transport', $exported );
    695695        $this->assertArrayHasKey( 'dirty', $exported );
    696         $this->assertEquals( $setting->js_value(), $exported['value'] );
    697         $this->assertEquals( $args['type'], $setting->type );
    698         $this->assertEquals( $args['transport'], $setting->transport );
    699         $this->assertEquals( $args['dirty'], $setting->dirty );
     696        $this->assertSame( $setting->js_value(), $exported['value'] );
     697        $this->assertSame( $args['type'], $setting->type );
     698        $this->assertSame( $args['transport'], $setting->transport );
     699        $this->assertSame( $args['dirty'], $setting->dirty );
    700700    }
    701701
     
    716716        $validity = $setting->validate( 'BAD!' );
    717717        $this->assertInstanceOf( 'WP_Error', $validity );
    718         $this->assertEquals( 'invalid_key', $validity->get_error_code() );
     718        $this->assertSame( 'invalid_key', $validity->get_error_code() );
    719719    }
    720720
     
    757757
    758758        $setting = new WP_Customize_Setting( $this->manager, $setting_id );
    759         $this->assertEquals( $initial_value, $setting->value() );
     759        $this->assertSame( $initial_value, $setting->value() );
    760760
    761761        $override_value = -123456;
     
    763763        $setting->preview();
    764764
    765         $this->assertEquals( $override_value, $setting->value() );
     765        $this->assertSame( $override_value, $setting->value() );
    766766    }
    767767}
Note: See TracChangeset for help on using the changeset viewer.