[dev] [commits] Horde branch master updated. 474895f80a889d60dd40536cbcc35e6c14d1a732

Jan Schneider jan at horde.org
Fri Feb 3 22:26:32 UTC 2012


Zitat von Michael M Slusarz <slusarz at horde.org>:

> Quoting Jan Schneider <jan at horde.org>:
>
>>>   This is stupid: PHPUnit won't allow expecting a plain old 'Exception'
>>>   exception.  Which just seems like blatant broken behavior to me.  There
>>>   are several built-in PHP classes that throw Exception natively (e.g.
>>>   DateTime), so you can't explicitly check for errors. Dumb.
>>
>> I guess the idea with expectedException might not be to test  
>> whether an exception occurred, but but to test that the correct  
>> exception occurred. Testing for "Exception" wouldn't make sense in  
>> this context because that would match any exception.
>
> But that's what expectedException is supposed to check for, at least  
> according to the documentation.  i.e. if you are expecting an  
> Exception, but an Extended_Exception is thrown, that *won't* be  
> caught because it is not an exception.
>
> This is not a try/catch() block where we are trying to prevent  
> exceptions bubbling to the main .  Which makes complete sense when  
> writing test units.  I create a test scenario where I know that an  
> Exception_Foo exception will be thrown.  What if there is an issue  
> in the code where an Exception_Foo_Extended exception is thrown.   
> That is not the expected behavior, and should not be caught.

Yes, makes sense.

Jan.

-- 
Do you need professional PHP or Horde consulting?
http://horde.org/consulting/



More information about the dev mailing list