mirror of
https://github.com/cerbero90/json-parser.git
synced 2025-01-17 21:18:41 +01:00
19 lines
780 B
PHP
19 lines
780 B
PHP
<?php
|
|
|
|
use Cerbero\JsonParser\Dataset;
|
|
use Cerbero\JsonParser\Exceptions\GuzzleRequiredException;
|
|
use Cerbero\JsonParser\Exceptions\UnsupportedSourceException;
|
|
use Cerbero\JsonParser\JsonParser;
|
|
use Cerbero\JsonParser\Sources\Source;
|
|
|
|
|
|
it('throws an exception when a JSON source is not supported', function () {
|
|
expect(fn () => JsonParser::parse(123)->traverse())
|
|
->toThrow(UnsupportedSourceException::class, 'Unable to load JSON from the provided source');
|
|
});
|
|
|
|
it('throws an exception when Guzzle is required but not installed', function (Source $source) {
|
|
expect(fn () => JsonParser::parse($source)->traverse())
|
|
->toThrow(GuzzleRequiredException::class, 'Guzzle is required to load JSON from endpoints');
|
|
})->with(Dataset::forSourcesRequiringGuzzle());
|