json-parser/tests/Feature/ParsingTest.php
Andrea Marco Sartori e93aacac78 Test eager loading
2023-03-22 23:36:00 +10:00

24 lines
808 B
PHP

<?php
use Cerbero\JsonParser\Dataset;
use Cerbero\JsonParser\JsonParser;
use function Cerbero\JsonParser\parseJson;
it('parses JSON when instantiated', function (string $json, array $parsed) {
expect(new JsonParser($json))->toParseTo($parsed);
})->with(Dataset::forParsing());
it('parses JSON when instantiated statically', function (string $json, array $parsed) {
expect(JsonParser::parse($json))->toParseTo($parsed);
})->with(Dataset::forParsing());
it('parses JSON when calling the helper', function (string $json, array $parsed) {
expect(parseJson($json))->toParseTo($parsed);
})->with(Dataset::forParsing());
it('eager loads JSON into an array', function (string $json, array $parsed) {
expect(JsonParser::parse($json)->toArray())->toBe($parsed);
})->with(Dataset::forParsing());