Files
pest/tests/Features/Expect/json.php
Daniel Ang c1b27579ca Method json() to parse JSON strings
- Parse a JSON string into array
- Test
2021-06-18 12:43:17 +02:00

15 lines
335 B
PHP

<?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);