Changeset 25785
- Timestamp:
- 10/15/2013 02:30:02 PM (11 years ago)
- Location:
- trunk/tests/phpunit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/testcase.php
r25408 r25785 9 9 protected $expected_deprecated = array(); 10 10 protected $caught_deprecated = array(); 11 protected $expected_doing_it_wrong = array(); 12 protected $caught_doing_it_wrong = array(); 11 13 12 14 /** … … 90 92 if ( ! empty( $annotations[ $depth ]['expectedDeprecated'] ) ) 91 93 $this->expected_deprecated = array_merge( $this->expected_deprecated, $annotations[ $depth ]['expectedDeprecated'] ); 94 if ( ! empty( $annotations[ $depth ]['expectedIncorrectUsage'] ) ) 95 $this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, $annotations[ $depth ]['expectedIncorrectUsage'] ); 92 96 } 93 97 add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ) ); 94 98 add_action( 'deprecated_argument_run', array( $this, 'deprecated_function_run' ) ); 99 add_action( 'doing_it_wrong_run', array( $this, 'doing_it_wrong_run' ) ); 95 100 add_action( 'deprecated_function_trigger_error', '__return_false' ); 96 101 add_action( 'deprecated_argument_trigger_error', '__return_false' ); 102 add_action( 'doing_it_wrong_trigger_error', '__return_false' ); 97 103 } 98 104 … … 107 113 $this->fail( "Unexpected deprecated notice for $unexpected" ); 108 114 } 115 116 $not_caught_doing_it_wrong = array_diff( $this->expected_doing_it_wrong, $this->caught_doing_it_wrong ); 117 foreach ( $not_caught_doing_it_wrong as $not_caught ) { 118 $this->fail( "Failed to assert that $not_caught triggered an incorrect usage notice" ); 119 } 120 121 $unexpected_doing_it_wrong = array_diff( $this->caught_doing_it_wrong, $this->expected_doing_it_wrong ); 122 foreach ( $unexpected_doing_it_wrong as $unexpected ) { 123 $this->fail( "Unexpected incorrect usage notice for $unexpected" ); 124 } 109 125 } 110 126 … … 112 128 if ( ! in_array( $function, $this->caught_deprecated ) ) 113 129 $this->caught_deprecated[] = $function; 130 } 131 132 function doing_it_wrong_run( $function ) { 133 if ( ! in_array( $function, $this->caught_doing_it_wrong ) ) 134 $this->caught_doing_it_wrong[] = $function; 114 135 } 115 136 -
trunk/tests/phpunit/tests/dependencies/jquery.php
r25375 r25785 39 39 /** 40 40 * @ticket 22896 41 * 42 * @expectedIncorrectUsage wp_deregister_script 41 43 */ 42 44 function test_dont_allow_deregister_core_scripts_in_admin() { … … 52 54 ); 53 55 54 add_action( 'doing_it_wrong_run', array( $this, 'doing_it_wrong_run' ) );55 56 56 foreach ( $libraries as $library ) { 57 57 // Try to deregister the script, which should fail. … … 60 60 } 61 61 62 remove_action( 'doing_it_wrong_run', array( $this, 'doing_it_wrong_run' ) );63 64 62 set_current_screen( 'front' ); 65 }66 67 function doing_it_wrong_run() {68 add_filter( 'doing_it_wrong_trigger_error', array( $this, 'doing_it_wrong_trigger_error' ) );69 }70 71 function doing_it_wrong_trigger_error() {72 remove_filter( 'doing_it_wrong_trigger_error', array( $this, 'doing_it_wrong_trigger_error' ) );73 return false;74 63 } 75 64 -
trunk/tests/phpunit/tests/theme/support.php
r25387 r25785 5 5 */ 6 6 class Tests_Theme_Support extends WP_UnitTestCase { 7 8 function setUp() {9 parent::setUp();10 add_action( 'doing_it_wrong_run', array( $this, 'doing_it_wrong_run' ) );11 }12 13 function tearDown() {14 parent::tearDown();15 remove_action( 'doing_it_wrong_run', array( $this, 'doing_it_wrong_run' ) );16 }17 18 function doing_it_wrong_run( $function ) {19 if ( in_array( $function, array( "add_theme_support( 'html5' )" ) ) )20 add_filter( 'doing_it_wrong_trigger_error', array( $this, 'doing_it_wrong_trigger_error' ) );21 }22 23 function doing_it_wrong_trigger_error() {24 remove_filter( 'doing_it_wrong_trigger_error', array( $this, 'doing_it_wrong_trigger_error' ) );25 return false;26 }27 7 28 8 function test_the_basics() { … … 116 96 /** 117 97 * @ticket 24932 98 * 99 * @expectedIncorrectUsage add_theme_support( 'html5' ) 118 100 */ 119 101 function test_supports_html5_subset() { … … 145 127 /** 146 128 * @ticket 24932 129 * 130 * @expectedIncorrectUsage add_theme_support( 'html5' ) 147 131 */ 148 132 function test_supports_html5_invalid() {
Note: See TracChangeset
for help on using the changeset viewer.