php - PHPUnit Assert One of two possible outcomes -
i writing unit tests validate functionality of 2 libraries same. essentially, testing interface.
however, in tests related error handling. error level different , has different because example, 1 generates e_warning , other can generate e_user_warning.
so question is. there assert in php unit can say, error must 1 of 2 possible results? like:
assertisin(array(e_warning, e_user_warning), $generatederror); i know work around swapping expected , actual answers on in assertcontains() or possibly pre-assert manipulation of results. there cleaner approach?
probably can implements assertcontains method (asserts haystack contains needle). example:
public function testassertisin() { $errorlevel = array(e_warning, e_user_warning); $generatederror = e_warning; $this->assertcontains($generatederror, $errorlevel); $generatederror = e_user_warning; $this->assertcontains($generatederror, $errorlevel); } hope help
Comments
Post a Comment