From 3e6c56c89cf772d6bfbe027d333bf812c45e2d0b Mon Sep 17 00:00:00 2001 From: Art4 Date: Fri, 27 Oct 2023 16:03:32 +0200 Subject: [PATCH] Add test for parsing format 1.1 properties --- tests/Functional/ParsingTest.php | 13 +++++++++++++ tests/files/18_jsonapi_object_with_ext_profile.json | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/files/18_jsonapi_object_with_ext_profile.json diff --git a/tests/Functional/ParsingTest.php b/tests/Functional/ParsingTest.php index 7d4bdc8..ea88979 100644 --- a/tests/Functional/ParsingTest.php +++ b/tests/Functional/ParsingTest.php @@ -671,4 +671,17 @@ public function testParseNormativeStatementsForVersion11Correctly(): void $this->assertCount(6, $document->get('data')->getKeys()); $this->assertCount(188, $document->get('included')->getKeys()); } + + public function testParseJsonApiObjectWithVersion11Correctly(): void + { + $string = $this->getJsonString('18_jsonapi_object_with_ext_profile.json'); + $document = Parser::parseResponseString($string); + + $this->assertInstanceOf('Art4\JsonApiClient\V1\Document', $document); + $this->assertSame(['meta', 'jsonapi'], $document->getKeys()); + $this->assertSame(['version'], $document->get('jsonapi')->getKeys()); + // TODO: Add support for unknown properties + // $this->assertSame(['version', 'ext', 'profile'], $document->get('jsonapi')->getKeys()); + $this->assertSame('1.1', $document->get('jsonapi.version')); + } } diff --git a/tests/files/18_jsonapi_object_with_ext_profile.json b/tests/files/18_jsonapi_object_with_ext_profile.json new file mode 100644 index 0000000..04750b0 --- /dev/null +++ b/tests/files/18_jsonapi_object_with_ext_profile.json @@ -0,0 +1,13 @@ +{ + "meta": {}, + "jsonapi": { + "version": "1.1", + "ext": [ + "https://jsonapi.org/ext/atomic" + ], + "profile": [ + "http://example.com/profiles/flexible-pagination", + "http://example.com/profiles/resource-versioning" + ] + } + }