Method json() to parse JSON strings

- Parse a JSON string into array
- Test
This commit is contained in:
Daniel Ang
2021-06-18 12:43:17 +02:00
parent 5116b4341e
commit c1b27579ca
2 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,14 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('it properly parses json string', function () {
expect('{"name":"Nuno"}')
->json()
->name
->toBe('Nuno');
});
test('fails with broken json string', function () {
expect('{":"Nuno"}')->json();
})->throws(ExpectationFailedException::class);