[Phpmyadmin-devel] PHPUnit and our error handler

Marc Delisle marc at infomarc.info
Tue Jan 15 14:37:48 CET 2013


Michal Čihař a écrit :
> Hi
> 
> Dne Mon, 14 Jan 2013 13:34:24 -0500
> Marc Delisle <marc at infomarc.info> napsal(a):
> 
>> Rouslan Placella a écrit :
>> Failed asserting that exception of type "PHPUnit_Framework_Error" is 
>> thrown. See attached patch.
>>
>>
> [..]
>> diff --git a/libraries/core.lib.php b/libraries/core.lib.php
>> index 93be5fe..eb698ff 100644
>> --- a/libraries/core.lib.php
>> +++ b/libraries/core.lib.php
>> @@ -277,7 +277,12 @@ function PMA_warnMissingExtension($extension, $fatal = false, $extra = '')
>>      if ($fatal) {
>>          PMA_fatalError($message);
>>      } else {
>> -        trigger_error($message, E_USER_WARNING);
>> +        $GLOBALS['error_handler']->addError(
>> +            $message, 
>> +            E_USER_WARNING,
>> +            '',
>> +            '',
>> +            $escape=false);
> 
> You no longer trigger PHP error here.
> 
>>      }
>>  }
>>  
>> diff --git a/test/libraries/core/PMA_warnMissingExtension_test.php b/test/libraries/core/PMA_warnMissingExtension_test.php
>> index 1e11c73..661e6c7 100644
>> --- a/test/libraries/core/PMA_warnMissingExtension_test.php
>> +++ b/test/libraries/core/PMA_warnMissingExtension_test.php
>> @@ -15,6 +15,11 @@ require_once 'libraries/core.lib.php';
>>  class PMA_warnMissingExtension_test extends PHPUnit_Framework_TestCase
>>  {
>>  
>> +    protected function setUp() {
>> +        require_once './libraries/Error_Handler.class.php';
>> +        $GLOBALS['error_handler'] = new PMA_Error_Handler();
>> +    }
>> +
>>      function testMissingExtention(){
>>          $ext = 'php_ext';
>>          $this->setExpectedException('PHPUnit_Framework_Error',
> 
> So it can not pop up as en error here. The addError method just adds it
> to list of errors in error handle for future display, but that does not
> trigger PHP error.

I think I understand now, working on it...


-- 
Marc Delisle
http://infomarc.info




More information about the Developers mailing list