Make WordPress Core

Changeset 1221 in tests for trunk/includes/testcase.php


Ignore:
Timestamp:
02/28/2013 04:30:21 PM (13 years ago)
Author:
nacin
Message:

During test execution, all wp_die() calls should throw an exception.

If the wp_die() call is not expected, the test will result in an error. Expected wp_die() calls may be caught with $this->setExpectedException( $exception ), @expectedException, etc. For more, see http://www.phpunit.de/manual/3.8/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.exceptions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/testcase.php

    r1127 r1221  
    1919        $this->clean_up_global_scope();
    2020        $this->start_transaction();
     21        add_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) );
    2122    }
    2223
     
    2627        remove_filter( 'dbdelta_create_queries', array( $this, '_create_temporary_tables' ) );
    2728        remove_filter( 'query', array( $this, '_drop_temporary_tables' ) );
     29        remove_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) );
    2830    }
    2931
     
    6264            return 'DROP TEMPORARY TABLE ' . substr( $query, 10 );
    6365        return $query;
     66    }
     67
     68    function get_wp_die_handler( $handler ) {
     69        return array( $this, 'wp_die_handler' );
     70    }
     71
     72    function wp_die_handler( $message ) {
     73        throw new WPDieException( $message );
    6474    }
    6575
Note: See TracChangeset for help on using the changeset viewer.