[Phpmyadmin-devel] PHPUnit and our error handler

Rouslan Placella rouslan at placella.com
Mon Jan 14 19:41:36 CET 2013


On 01/14/2013 06:34 PM, Marc Delisle wrote:
> Rouslan Placella a écrit :
>> On 01/14/2013 06:00 PM, Marc Delisle wrote:
>>> Hi,
>>> I want to modify a test to fit with a modification I am working on. In
>>> this modification, the tested function uses $GLOBALS['error_handler'].
>>> How can I define this global inside my test?
>>
>> How about the below code? Totally untested, off the top of my head,
>> but should work....
>>
>> protected function setUp()
>> {
>>      $GLOBALS['error_handler'] = new PMA_Error_Handler();
>> }
>
> Thanks. I added this (plus the "require" for the error class) but now I get
>
> Failed asserting that exception of type "PHPUnit_Framework_Error" is
> thrown. See attached patch.

Is the test supposed to throw a PHP error (I haven't run the test yet)? 
If yes, you just need to tell the test to expect it. This is explained 
in the "Testing Exceptions" section of phpunit documentation:

http://www.phpunit.de/manual/3.2/en/writing-tests-for-phpunit.html#id323367

Bye,
Rouslan





More information about the Developers mailing list