Skip to content

Commit

Permalink
Add throws, change error message + add class name
Browse files Browse the repository at this point in the history
  • Loading branch information
DFoxinator authored and sebastianbergmann committed Jul 31, 2019
1 parent 23026a1 commit bbd09bb
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/Framework/MockObject/MockBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,22 @@ public function setMethods(array $methods = null): self
* Specifies the subset of methods to mock, requiring each to exist in the class
*
* @param string[] $methods
*
* @throws RuntimeException
*/
public function setRealMethods(array $methods): self
{
if ($methods) {
$reflection = new \ReflectionClass($this->type);

foreach ($methods as $method) {
if (!$reflection->hasMethod($method)) {
throw new RuntimeException(
\sprintf(
'Trying to set mock method "%s" which cannot be configured because it does not exist',
$method
)
);
}
$reflection = new \ReflectionClass($this->type);

foreach ($methods as $method) {
if (!$reflection->hasMethod($method)) {
throw new RuntimeException(
\sprintf(
'Trying to set mock method "%s", but it does not exist in class "%s"',
$method,
$this->type
)
);
}
}

Expand Down

0 comments on commit bbd09bb

Please sign in to comment.