Changeset 35007 for trunk/tests/phpunit/tests/customize/setting.php
- Timestamp:
- 10/10/2015 09:05:04 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/customize/setting.php
r34838 r35007 103 103 $this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $name, $this->undefined ) ); 104 104 $this->assertEquals( $default, $setting->value() ); 105 $ setting->preview();105 $this->assertTrue( $setting->preview(), 'Preview should not no-op since setting has no existing value.' ); 106 106 $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 ) ); 107 107 $this->assertEquals( $default, $setting->value() ); … … 115 115 $this->assertEquals( $initial_value, call_user_func( $type_options['getter'], $name ) ); 116 116 $this->assertEquals( $initial_value, $setting->value() ); 117 $ setting->preview();117 $this->assertFalse( $setting->preview(), 'Preview should no-op since setting value was extant and no post value was present.' ); 118 118 $this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // only applicable for custom types (not options or theme_mods) 119 119 $this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // only applicable for custom types (not options or theme_mods) … … 121 121 $this->assertEquals( $initial_value, $setting->value() ); 122 122 123 // @todo What if we call the setter after preview() is called? If no post_value, should the new set value be stored? If that happens, then the following 3 assertions should be inverted124 123 $overridden_value = "overridden_value_$name"; 125 124 call_user_func( $type_options['setter'], $name, $overridden_value ); 126 $this->assertEquals( $initial_value, call_user_func( $type_options['getter'], $name ) ); 127 $this->assertEquals( $initial_value, $setting->value() ); 128 $this->assertNotEquals( $overridden_value, $setting->value() ); 125 $message = 'Initial value should be overridden because initial preview() was no-op due to setting having existing value and/or post value was absent.'; 126 $this->assertEquals( $overridden_value, call_user_func( $type_options['getter'], $name ), $message ); 127 $this->assertEquals( $overridden_value, $setting->value(), $message ); 128 $this->assertNotEquals( $initial_value, $setting->value(), $message ); 129 129 130 130 // Non-multidimensional: Test unset setting being overridden by a post value … … 134 134 $this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $name, $this->undefined ) ); 135 135 $this->assertEquals( $default, $setting->value() ); 136 $ setting->preview(); // activate post_data136 $this->assertTrue( $setting->preview(), 'Preview applies because setting has post_data_overrides.' ); // activate post_data 137 137 $this->assertEquals( $this->post_data_overrides[ $name ], call_user_func( $type_options['getter'], $name, $this->undefined ) ); 138 138 $this->assertEquals( $this->post_data_overrides[ $name ], $setting->value() ); … … 146 146 $this->assertEquals( $initial_value, call_user_func( $type_options['getter'], $name, $this->undefined ) ); 147 147 $this->assertEquals( $initial_value, $setting->value() ); 148 $ setting->preview(); // activate post_data148 $this->assertTrue( $setting->preview(), 'Preview applies because setting has post_data_overrides.' ); // activate post_data 149 149 $this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // only applicable for custom types (not options or theme_mods) 150 150 $this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // only applicable for custom types (not options or theme_mods) … … 168 168 $this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $base_name, $this->undefined ) ); 169 169 $this->assertEquals( $default, $setting->value() ); 170 $ setting->preview();170 $this->assertTrue( $setting->preview() ); 171 171 $base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined ); 172 172 $this->assertArrayHasKey( 'foo', $base_value ); … … 312 312 $this->assertEquals( $initial_value, $setting->value() ); 313 313 $setting->preview(); 314 $this->assertEquals( 1, did_action( "customize_preview_{$setting->id}" ));315 $this->assertEquals( 2, did_action( "customize_preview_{$setting->type}" ) );314 $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.' ); 315 $this->assertEquals( 1, did_action( "customize_preview_{$setting->type}" ) ); 316 316 $this->assertEquals( $initial_value, $this->custom_type_getter( $name, $this->undefined ) ); // should be same as above 317 317 $this->assertEquals( $initial_value, $setting->value() ); // should be same as above … … 326 326 $this->assertEquals( $default, $setting->value() ); 327 327 $setting->preview(); 328 $this->assertEquals( 1, did_action( "customize_preview_{$setting->id}" ) );329 $this->assertEquals( 3, did_action( "customize_preview_{$setting->type}" ) );328 $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.' ); 329 $this->assertEquals( 2, did_action( "customize_preview_{$setting->type}" ) ); 330 330 $this->assertEquals( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) ); 331 331 $this->assertEquals( $post_data_overrides[ $name ], $setting->value() ); … … 343 343 $setting->preview(); 344 344 $this->assertEquals( 1, did_action( "customize_preview_{$setting->id}" ) ); 345 $this->assertEquals( 4, did_action( "customize_preview_{$setting->type}" ) );345 $this->assertEquals( 3, did_action( "customize_preview_{$setting->type}" ) ); 346 346 $this->assertEquals( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) ); 347 347 $this->assertEquals( $post_data_overrides[ $name ], $setting->value() );
Note: See TracChangeset
for help on using the changeset viewer.