Changeset 37700 for trunk/tests/phpunit/tests/customize/manager.php
- Timestamp:
- 06/14/2016 07:16:54 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/customize/manager.php
r37476 r37700 197 197 */ 198 198 function test_validate_setting_values() { 199 $default_value = 'foo_default';200 199 $setting = $this->manager->add_setting( 'foo', array( 201 200 'validate_callback' => array( $this, 'filter_customize_validate_foo' ), … … 205 204 $post_value = 'bar'; 206 205 $this->manager->set_post_value( 'foo', $post_value ); 207 $this->assertEmpty( $this->manager->validate_setting_values( $this->manager->unsanitized_post_values() ) ); 206 $validities = $this->manager->validate_setting_values( $this->manager->unsanitized_post_values() ); 207 $this->assertCount( 1, $validities ); 208 $this->assertEquals( array( 'foo' => true ), $validities ); 208 209 209 210 $this->manager->set_post_value( 'foo', 'return_wp_error_in_sanitize' ); … … 235 236 236 237 /** 238 * Test WP_Customize_Manager::prepare_setting_validity_for_js(). 239 * 240 * @see WP_Customize_Manager::prepare_setting_validity_for_js() 241 */ 242 function test_prepare_setting_validity_for_js() { 243 $this->assertTrue( $this->manager->prepare_setting_validity_for_js( true ) ); 244 $error = new WP_Error(); 245 $error->add( 'bad_letter', 'Bad letter' ); 246 $error->add( 'bad_letter', 'Bad letra' ); 247 $error->add( 'bad_number', 'Bad number', array( 'number' => 123 ) ); 248 $validity = $this->manager->prepare_setting_validity_for_js( $error ); 249 $this->assertInternalType( 'array', $validity ); 250 foreach ( $error->errors as $code => $messages ) { 251 $this->assertArrayHasKey( $code, $validity ); 252 $this->assertInternalType( 'array', $validity[ $code ] ); 253 $this->assertEquals( join( ' ', $messages ), $validity[ $code ]['message'] ); 254 $this->assertArrayHasKey( 'data', $validity[ $code ] ); 255 $this->assertArrayHasKey( 'from_server', $validity[ $code ]['data'] ); 256 } 257 $this->assertArrayHasKey( 'number', $validity['bad_number']['data'] ); 258 $this->assertEquals( 123, $validity['bad_number']['data']['number'] ); 259 } 260 261 /** 237 262 * Test WP_Customize_Manager::set_post_value(). 238 263 * … … 566 591 $this->assertArrayHasKey( 'activeSections', $settings ); 567 592 $this->assertArrayHasKey( 'activeControls', $settings ); 593 $this->assertArrayHasKey( 'settingValidities', $settings ); 568 594 $this->assertArrayHasKey( 'nonce', $settings ); 569 595 $this->assertArrayHasKey( '_dirty', $settings );
Note: See TracChangeset
for help on using the changeset viewer.