wip toward lvl9

This commit is contained in:
Fabio Ivona
2021-11-18 01:01:56 +01:00
parent d4a8a3ec37
commit 7bcd3ebaee
8 changed files with 39 additions and 7 deletions

View File

@ -9,6 +9,7 @@ use Closure;
use InvalidArgumentException;
use Pest\Concerns\Extendable;
use Pest\Concerns\RetrievesValues;
use Pest\Exceptions\ExpectationException;
use Pest\Support\Arr;
use Pest\Support\NullClosure;
use PHPUnit\Framework\Assert;
@ -68,6 +69,10 @@ final class Expectation
*/
public function json(): Expectation
{
if (!is_string($this->value)) {
throw ExpectationException::invalidValue('json', 'string');
}
return $this->toBeJson()->and(json_decode($this->value, true));
}