mirror of
https://github.com/pestphp/pest.git
synced 2026-03-11 18:27:23 +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 BadMethodCallException;
|
||||||
use Closure;
|
use Closure;
|
||||||
|
use Error;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Pest\Exceptions\InvalidExpectationValue;
|
use Pest\Exceptions\InvalidExpectationValue;
|
||||||
use Pest\Support\Arr;
|
use Pest\Support\Arr;
|
||||||
@ -824,6 +825,10 @@ final class Expectation
|
|||||||
($this->value)();
|
($this->value)();
|
||||||
} catch (Throwable $e) { // @phpstan-ignore-line
|
} catch (Throwable $e) { // @phpstan-ignore-line
|
||||||
if (!class_exists($exception)) {
|
if (!class_exists($exception)) {
|
||||||
|
if ($e instanceof Error && $e->getMessage() === "Class \"$exception\" not found") {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
Assert::assertStringContainsString($exception, $e->getMessage());
|
Assert::assertStringContainsString($exception, $e->getMessage());
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|||||||
Reference in New Issue
Block a user