Mockery\Expectation::andThrow PHP Метод

andThrow() публичный Метод

Set Exception class and arguments to that class to be thrown
public andThrow ( string | Exception $exception, string $message = '', integer $code, Exception $previous = null ) : self
$exception string | Exception
$message string
$code integer
$previous Exception
Результат self
    public function andThrow($exception, $message = '', $code = 0, \Exception $previous = null)
    {
        $this->_throw = true;
        if (is_object($exception)) {
            $this->andReturn($exception);
        } else {
            $this->andReturn(new $exception($message, $code, $previous));
        }
        return $this;
    }

Usage Example

 /**
  * @return $this
  */
 public function andThrow($exception, $message = '', $code = 0, \Exception $previous = null)
 {
     $this->expectation->andThrow($exception, $message, $code, $previous);
     return $this;
 }