mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
handles toThrow exception with a "class not found" error
This commit is contained in:
@ -6,6 +6,7 @@ namespace Pest\Mixins;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Closure;
|
||||
use Error;
|
||||
use InvalidArgumentException;
|
||||
use Pest\Exceptions\InvalidExpectationValue;
|
||||
use Pest\Support\Arr;
|
||||
@ -824,6 +825,10 @@ final class Expectation
|
||||
($this->value)();
|
||||
} catch (Throwable $e) { // @phpstan-ignore-line
|
||||
if (!class_exists($exception)) {
|
||||
if ($e instanceof Error && $e->getMessage() === "Class \"$exception\" not found") {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
Assert::assertStringContainsString($exception, $e->getMessage());
|
||||
|
||||
return $this;
|
||||
|
||||
Reference in New Issue
Block a user