Make WordPress Core

Changeset 101 in tests


Ignore:
Timestamp:
12/03/2007 10:52:17 PM (18 years ago)
Author:
tellyworth
Message:

make sure errors are handled the same way in different environments

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-test.php

    r85 r101  
    2222// make sure errors are displayed during setup
    2323error_reporting(E_ALL);
    24 ini_set('display_errors', '1');
     24ini_set('display_errors', true);
    2525
    2626require_once(DIR_TESTROOT.'/wp-testlib/base.php');
     
    8787do_action('test_start');
    8888
    89 // hide errors during test runs, since they're captured and reported by the test framework
    90 ini_set('display_errors', '0');
     89// hide warnings during testing, since that's the normal WP behaviour
     90error_reporting(E_ALL ^ E_NOTICE);
    9191// run the tests and print the results
    9292$result = wptest_run_tests($classes, @$opts['t']);
  • wp-testlib/base.php

    r86 r101  
    1818        // error types taken from PHPUnit_Framework_TestResult::run
    1919        $this->_phpunit_err_mask = E_USER_ERROR | E_NOTICE | E_STRICT;
    20         if (version_compare(phpversion(), '5.2.0RC1', '>=')) {
    21             $this->_phpunit_err_mask |= E_RECOVERABLE_ERROR;
    22         }
    2320        $this->_old_handler = set_error_handler(array(&$this, '_error_handler'));
    2421        if (is_null($this->_old_handler)) {
     
    3835    function _error_handler($errno, $errstr, $errfile, $errline) {
    3936        // @ in front of statement
    40         if (0 ==  ini_get('error_reporting')) {
     37        if (error_reporting() == 0) {
    4138            return;
    4239        }
     40        // notices and strict warnings are passed on to the phpunit error handler but don't trigger an exception
    4341        if ($errno | $this->_phpunit_err_mask) {
    4442            PHPUnit_Util_ErrorHandler($errno, $errstr, $errfile, $errline);
    45         } else {
     43        }
     44        // warnings and errors trigger an exception, which is included in the test results
     45        else {
    4646            error_log("Testing: $errstr in $errfile on line $errline");
    4747            //TODO: we should raise custom exception here, sth like WP_PHPError
    48             throw new PHPUnit_Framework_Error(
     48            throw new PHPUnit_Framework_Error(
    4949                $errstr,
    5050                $errno,
Note: See TracChangeset for help on using the changeset viewer.