Skip to content

Commit

Permalink
Improve error message for getMock's invalid $methods argument
Browse files Browse the repository at this point in the history
Now gives better error message:
```
There was 1 error:

1) ExampleTest::testExample
PHPUnit_Framework_Exception: Argument sebastianbergmann#2 (string#__construct)of PHPUnit_Framework_MockObject_Generator::getMock() must be a array

/<path>/ExampleTest.php:8
```

Instead of:
```
There was 1 error:

1) ExampleTest::testExample
InvalidArgumentException: 

/<path>/ExampleTest.php:8
```
  • Loading branch information
sustmi authored and sebastianbergmann committed Aug 9, 2015
1 parent 96efe0b commit 4d19fcb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Framework/MockObject/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function getMock($type, $methods = [], array $arguments = [], $mockClassN
}

if (!is_array($methods) && !is_null($methods)) {
throw new InvalidArgumentException;
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'array', $methods);
}

if ($type === 'Traversable' || $type === '\\Traversable') {
Expand Down

0 comments on commit 4d19fcb

Please sign in to comment.