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 committed May 11, 2019
1 parent e92338d commit 6421ecc
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/Framework/MockObject/MockBuilder.php
Expand Up @@ -182,21 +182,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 6421ecc

Please sign in to comment.