Ticket #37082: 37082.2.diff
File 37082.2.diff, 3.4 KB (added by , 8 years ago) |
---|
-
tests/phpunit/tests/customize/setting.php
48 48 $this->assertEquals( false, $setting->dirty ); 49 49 } 50 50 51 /** 52 * A test validate callback function. 53 */ 54 function validate_callback_for_tests( $value ) { 55 return $value . ':validate_callback'; 56 } 57 58 /** 59 * A test sanitize callback function. 60 */ 61 function sanitize_callback_for_tests( $value ) { 62 return $value . ':sanitize_callback'; 63 } 64 65 /** 66 * A test sanitize JS callback function. 67 */ 68 function sanitize_js_callback_for_tests( $value ) { 69 return $value . ':sanitize_js_callback'; 70 } 71 51 72 function test_constructor_with_args() { 52 73 $args = array( 53 74 'type' => 'option', … … 55 76 'theme_supports' => 'widgets', 56 77 'default' => 'barbar', 57 78 'transport' => 'postMessage', 58 'validate_callback' => create_function( '$value', 'return $value . ":validate_callback";' ),59 'sanitize_callback' => create_function( '$value', 'return $value . ":sanitize_callback";' ),60 'sanitize_js_callback' => create_function( '$value', 'return $value . ":sanitize_js_callback";' ),79 'validate_callback' => array( $this, 'validate_callback_for_tests' ), 80 'sanitize_callback' => array( $this, 'sanitize_callback_for_tests' ), 81 'sanitize_js_callback' => array( $this, 'sanitize_js_callback_for_tests' ), 61 82 ); 62 83 $setting = new WP_Customize_Setting( $this->manager, 'bar', $args ); 63 84 $this->assertEquals( 'bar', $setting->id ); … … 603 624 } 604 625 605 626 /** 627 * Sanitize JS callback for base64 encoding. 628 */ 629 function sanitize_js_callback_base64_for_testing( $value ) { 630 return base64_encode( $value ); 631 } 632 633 /** 606 634 * Test js_value and json methods. 607 635 * 608 636 * @see WP_Customize_Setting::js_value() … … 615 643 'default' => $default, 616 644 'transport' => 'postMessage', 617 645 'dirty' => true, 618 'sanitize_js_callback' => create_function( '$value', 'return base64_encode( $value );' ),646 'sanitize_js_callback' => array( $this, 'sanitize_js_callback_base64_for_testing' ), 619 647 ); 620 648 $setting = new WP_Customize_Setting( $this->manager, 'name', $args ); 621 649 -
tests/phpunit/tests/image/editor.php
46 46 } 47 47 48 48 /** 49 * Return integer of 95 for testing. 50 */ 51 function return_integer_95() { 52 return 95; 53 } 54 55 /** 56 * Return integer of 100 for testing. 57 */ 58 function return_integer_100() { 59 return 100; 60 } 61 62 /** 49 63 * Test test_quality 50 64 * @ticket 6821 51 65 */ … … 59 73 $this->assertEquals( 82, $editor->get_quality() ); 60 74 61 75 // Ensure the quality filters do not have precedence if created after editor instantiation. 62 $func_100_percent = create_function( '', "return 100;");76 $func_100_percent = array( $this, 'return_integer_100' ); 63 77 add_filter( 'wp_editor_set_quality', $func_100_percent ); 64 78 $this->assertEquals( 82, $editor->get_quality() ); 65 79 66 $func_95_percent = create_function( '', "return 95;");80 $func_95_percent = array( $this, 'return_integer_95' ); 67 81 add_filter( 'jpeg_quality', $func_95_percent ); 68 82 $this->assertEquals( 82, $editor->get_quality() ); 69 83