Changeset 40392
- Timestamp:
- 04/07/2017 01:37:39 PM (8 years ago)
- Location:
- trunk/tests/phpunit/tests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/customize/setting.php
r40036 r40392 49 49 } 50 50 51 /** 52 * A test validate callback function. 53 * 54 * @param mixed $value The setting value. 55 * @param WP_Customize_Setting $setting The setting object. 56 */ 57 public function validate_callback_for_tests( $value, $setting ) { 58 return $value . ':validate_callback'; 59 } 60 61 /** 62 * A test sanitize callback function. 63 * 64 * @param mixed $value The setting value. 65 * @param WP_Customize_Setting $setting The setting object. 66 */ 67 public function sanitize_callback_for_tests( $value, $setting ) { 68 return $value . ':sanitize_callback'; 69 } 70 71 /** 72 * A test sanitize JS callback function. 73 * 74 * @param mixed $value The setting value. 75 * @param WP_Customize_Setting $setting The setting object. 76 */ 77 public function sanitize_js_callback_for_tests( $value, $setting ) { 78 return $value . ':sanitize_js_callback'; 79 } 80 81 /** 82 * Sanitize JS callback for base64 encoding. 83 * 84 * @param mixed $value The setting value. 85 * @param WP_Customize_Setting $setting The setting object. 86 */ 87 function sanitize_js_callback_base64_for_testing( $value, $setting ) { 88 return base64_encode( $value ); 89 } 90 51 91 function test_constructor_with_args() { 52 92 $args = array( … … 56 96 'default' => 'barbar', 57 97 '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";' ),98 'validate_callback' => array( $this, 'validate_callback_for_tests' ), 99 'sanitize_callback' => array( $this, 'sanitize_callback_for_tests' ), 100 'sanitize_js_callback' => array( $this, 'sanitize_js_callback_for_tests' ), 61 101 ); 62 102 $setting = new WP_Customize_Setting( $this->manager, 'bar', $args ); … … 616 656 'transport' => 'postMessage', 617 657 'dirty' => true, 618 'sanitize_js_callback' => create_function( '$value', 'return base64_encode( $value );' ),658 'sanitize_js_callback' => array( $this, 'sanitize_js_callback_base64_for_testing' ), 619 659 ); 620 660 $setting = new WP_Customize_Setting( $this->manager, 'name', $args ); -
trunk/tests/phpunit/tests/image/editor.php
r36616 r40392 47 47 48 48 /** 49 * Return integer of 95 for testing. 50 */ 51 public function return_integer_95() { 52 return 95; 53 } 54 55 /** 56 * Return integer of 100 for testing. 57 */ 58 public function return_integer_100() { 59 return 100; 60 } 61 62 /** 49 63 * Test test_quality 50 64 * @ticket 6821 … … 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() );
Note: See TracChangeset
for help on using the changeset viewer.