Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add throws, change error message + add class name
  • Loading branch information
DFoxinator committed Jul 16, 2019
commit d2f1f5075453e31d80bdde94e3e668d460f2c3fe
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