Skip to content

Commit

Permalink
Add test for parsing format 1.1 properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Art4 committed Oct 27, 2023
1 parent ea12636 commit 3e6c56c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/Functional/ParsingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -671,4 +671,17 @@ public function testParseNormativeStatementsForVersion11Correctly(): void
$this->assertCount(6, $document->get('data')->getKeys());

Check failure on line 671 in tests/Functional/ParsingTest.php

View workflow job for this annotation

GitHub Actions / Run PHPStan with PHP 8.2

Cannot call method getKeys() on mixed.
$this->assertCount(188, $document->get('included')->getKeys());

Check failure on line 672 in tests/Functional/ParsingTest.php

View workflow job for this annotation

GitHub Actions / Run PHPStan with PHP 8.2

Cannot call method getKeys() on mixed.
}

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

Check failure on line 682 in tests/Functional/ParsingTest.php

View workflow job for this annotation

GitHub Actions / Run PHPStan with PHP 8.2

Cannot call method getKeys() on mixed.
// TODO: Add support for unknown properties
// $this->assertSame(['version', 'ext', 'profile'], $document->get('jsonapi')->getKeys());
$this->assertSame('1.1', $document->get('jsonapi.version'));
}
}
13 changes: 13 additions & 0 deletions tests/files/18_jsonapi_object_with_ext_profile.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}

0 comments on commit 3e6c56c

Please sign in to comment.