WordPress.org

Make WordPress Core

Changeset 289 in tests


Ignore:
Timestamp:
01/21/10 22:41:47 (4 years ago)
Author:
westi
Message:

Allow test cases to disable wp_die temporarily so that tests can run assertions which cause wp_die's in normal running. See WP#11892

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wp-test.php

    r288 r289  
    7171require_once(ABSPATH.'wp-settings.php'); 
    7272 
     73// Allow tests to override wp_die 
     74add_filter( 'wp_die_handler', '_wp_die_handler_filter' ); 
     75 
    7376drop_tables(); 
    74  
    7577 
    7678if (TEST_MU) 
  • wp-testcase/test_user_capabilities.php

    r199 r289  
    122122    // a role that doesn't exist 
    123123    function test_bogus_role() { 
     124        _disable_wp_die(); 
    124125        $id = $this->_make_user(rand_str()); 
    125126        $user = new WP_User($id); 
     
    128129        $this->assertEquals(array(), $user->roles); 
    129130        $this->assertFalse($user->has_cap('level_0')); 
     131        _enable_wp_die(); 
    130132    } 
    131133 
  • wp-testlib/base.php

    r227 r289  
    2525            restore_error_handler(); 
    2626        } 
     27        _enable_wp_die(); 
    2728 
    2829        set_time_limit($this->_time_limit); 
     
    3334            restore_error_handler(); 
    3435        } 
     36        _enable_wp_die(); 
    3537    } 
    3638     
  • wp-testlib/utils.php

    r102 r289  
    302302} 
    303303 
     304$GLOBALS['_wp_die_disabled'] = false; 
     305function _wp_die_handler( $message, $title = '', $args = array() ) { 
     306    if ( !$GLOBALS['_wp_die_disabled'] ) { 
     307        _default_wp_die_handler( $message, $title, $args ); 
     308    } else { 
     309        //Ignore at our peril 
     310    } 
     311} 
     312 
     313function _disable_wp_die() { 
     314    $GLOBALS['_wp_die_disabled'] = true; 
     315} 
     316 
     317function _enable_wp_die() { 
     318    $GLOBALS['_wp_die_disabled'] = false; 
     319} 
     320 
     321function _wp_die_handler_filter() { 
     322    return '_wp_die_handler'; 
     323} 
     324 
    304325?> 
Note: See TracChangeset for help on using the changeset viewer.