mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Method json() to parse JSON strings
- Parse a JSON string into array - Test
This commit is contained in:
14
tests/Features/Expect/json.php
Normal file
14
tests/Features/Expect/json.php
Normal 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);
|
||||
Reference in New Issue
Block a user