mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Add toSnapshot() early return
Sometimes objects need native toString() and toArray() methods that are different from what you want to snapshot. This adds an explicit toSnapshot() method that will be called first (when set) allowing for better snapshot values than the generic methods offer.
This commit is contained in:
@ -844,6 +844,7 @@ final class Expectation
|
||||
|
||||
$string = match (true) {
|
||||
is_string($this->value) => $this->value,
|
||||
is_object($this->value) && method_exists($this->value, 'toSnapshot') => $this->value->toSnapshot(),
|
||||
is_object($this->value) && method_exists($this->value, '__toString') => $this->value->__toString(),
|
||||
is_object($this->value) && method_exists($this->value, 'toString') => $this->value->toString(),
|
||||
$this->value instanceof \Illuminate\Testing\TestResponse => $this->value->getContent(), // @phpstan-ignore-line
|
||||
|
||||
Reference in New Issue
Block a user