Skip to content

Commit

Permalink
Throw specific Exceptions when add_method fails
Browse files Browse the repository at this point in the history
  • Loading branch information
sirbrillig committed Oct 23, 2017
1 parent afb844d commit f542957
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Spies/MockObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ public function add_method( $function_name, $function = null ) {
'and_ignore_missing',
];
if ( in_array( $function_name, $reserved_method_names ) ) {
throw new \Exception( 'The function "' . $function_name . '" added to this mock object could not be used because it conflicts with a built-in function' );
throw new \Spies\InvalidFunctionNameException( 'The function "' . $function_name . '" added to this mock object could not be used because it conflicts with a built-in function' );
}
if ( ! is_callable( $function ) ) {
throw new \Exception( 'The function "' . $function_name . '" added to this mock object was not a function' );
throw new \InvalidArgumentException( 'The function "' . $function_name . '" added to this mock object was not a function' );
}
if ( $function instanceof Spy && $this->delegate_instance ) {
$function->will_return( [ $this->delegate_instance, $function_name ] );
Expand Down

0 comments on commit f542957

Please sign in to comment.