Permalink
Browse files

Assert::error() accepts array of E_XXXX without error message

  • Loading branch information...
dg committed Jun 7, 2018
1 parent 333e397 commit 38c23f491815d2ed5984a919bd9c143f435b903d
Showing with 16 additions and 1 deletion.
  1. +2 βˆ’1 src/Framework/Assert.php
  2. +14 βˆ’0 tests/Framework/Assert.error.phpt
@@ -336,7 +336,8 @@ public static function error(callable $function, $expectedType, $expectedMessage
self::$counter++;
$expected = is_array($expectedType) ? $expectedType : [[$expectedType, $expectedMessage]];
foreach ($expected as &$item) {
list($expectedType, $expectedMessage) = $item;
$item = ((array) $item) + [null, null];
$expectedType = $item[0];
if (is_int($expectedType)) {
$item[2] = Helpers::errorTypeToString($expectedType);
} elseif (is_string($expectedType)) {
@@ -26,6 +26,20 @@ Assert::error(function () {
[E_NOTICE, 'Undefined variable: b'],
]);
Assert::error(function () {
$a++;
$b++;
}, [
[E_NOTICE],
[E_NOTICE],
]);
Assert::error(function () {
$a++;
$b++;
}, [E_NOTICE, E_NOTICE]
);
Assert::exception(function () {
Assert::error(function () {
}, E_NOTICE);

0 comments on commit 38c23f4

Please sign in to comment.