diff --git a/.travis.yml b/.travis.yml index 8ba1558..fe3c026 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ language: php php: - '7.1' + - '7.2' + - '7.3' before_script: - composer install diff --git a/CHANGELOG.md b/CHANGELOG.md index 86ca5ab..9185eeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [2.1.0] - 2019-02-25 +### Fixed +- Relationship without data property (#92) + ## [2.0.1] - 2018-12-31 ### Changed - Downgraded min required php version to 7.1 @@ -14,5 +18,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added - v2 initial release -[Unreleased]: https://github.com/json-api-php/json-api/compare/2.0.1...HEAD +[Unreleased]: https://github.com/json-api-php/json-api/compare/2.1.0...HEAD +[2.1.0]: https://github.com/json-api-php/json-api/compare/2.0.1...2.1.0 [2.0.1]: https://github.com/json-api-php/json-api/compare/2.0.0...2.0.1 diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 48bfa68..884a29a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,8 +3,7 @@ bootstrap="vendor/autoload.php" stopOnFailure="false" verbose="true" - colors="true" - syntaxCheck="true"> + colors="true"> ./test diff --git a/src/EmptyRelationship.php b/src/EmptyRelationship.php new file mode 100644 index 0000000..1482792 --- /dev/null +++ b/src/EmptyRelationship.php @@ -0,0 +1,31 @@ +name = $name; + $this->obj = combine($member, ...$members); + } + + /** + * @param object $o + */ + public function attachTo($o): void + { + child($o, 'relationships')->{$this->name} = $this->obj; + } +} diff --git a/src/Error/SourceParameter.php b/src/Error/SourceParameter.php index 05b711a..f3bc37a 100644 --- a/src/Error/SourceParameter.php +++ b/src/Error/SourceParameter.php @@ -2,8 +2,8 @@ namespace JsonApiPhp\JsonApi\Error; -use JsonApiPhp\JsonApi\Internal\ErrorMember; use function JsonApiPhp\JsonApi\child; +use JsonApiPhp\JsonApi\Internal\ErrorMember; final class SourceParameter implements ErrorMember { diff --git a/src/Error/SourcePointer.php b/src/Error/SourcePointer.php index 84815db..0af0b5b 100644 --- a/src/Error/SourcePointer.php +++ b/src/Error/SourcePointer.php @@ -2,8 +2,8 @@ namespace JsonApiPhp\JsonApi\Error; -use JsonApiPhp\JsonApi\Internal\ErrorMember; use function JsonApiPhp\JsonApi\child; +use JsonApiPhp\JsonApi\Internal\ErrorMember; final class SourcePointer implements ErrorMember { diff --git a/src/Internal/RelationshipMember.php b/src/Internal/RelationshipMember.php new file mode 100644 index 0000000..3746dee --- /dev/null +++ b/src/Internal/RelationshipMember.php @@ -0,0 +1,10 @@ +validateFieldName($name); $this->name = $name; diff --git a/test/CompoundDocumentTest.php b/test/CompoundDocumentTest.php index 3d62ff9..7441200 100644 --- a/test/CompoundDocumentTest.php +++ b/test/CompoundDocumentTest.php @@ -253,11 +253,11 @@ public function testIncludedResourceMayBeIdentifiedByAnotherLinkedResource() /** * A compound document MUST NOT include more than one resource object for each type and id pair. - * @expectedException \LogicException - * @expectedExceptionMessage Resource apples:1 is already included */ public function testCanNotBeManyIncludedResourcesWithEqualIdentifiers() { + $this->expectException('LogicException'); + $this->expectExceptionMessage('Resource apples:1 is already included'); $apple = new ResourceObject('apples', '1'); new CompoundDocument($apple->identifier(), new Included($apple, $apple)); } diff --git a/test/ResourceObjectTest.php b/test/ResourceObjectTest.php index 37e845f..3541c8d 100644 --- a/test/ResourceObjectTest.php +++ b/test/ResourceObjectTest.php @@ -4,6 +4,7 @@ use JsonApiPhp\JsonApi\Attribute; use JsonApiPhp\JsonApi\DataDocument; +use JsonApiPhp\JsonApi\EmptyRelationship; use JsonApiPhp\JsonApi\Link\RelatedLink; use JsonApiPhp\JsonApi\Link\SelfLink; use JsonApiPhp\JsonApi\Meta; @@ -152,6 +153,63 @@ public function testRelationshipWithEmptyMultiIdLinkage() ); } + public function testRelationshipWithNoData() + { + $this->assertEncodesTo( + ' + { + "data": { + "type": "basket", + "id": "1", + "relationships": { + "empty": { + "links": { + "related": "/foo" + } + } + } + } + } + ', + new DataDocument( + new ResourceObject( + 'basket', + '1', + new EmptyRelationship('empty', new RelatedLink('/foo')) + ) + ) + ); + + $this->assertEncodesTo( + ' + { + "data": { + "type": "basket", + "id": "1", + "relationships": { + "empty": { + "links": { + "related": "/foo", + "self": "/bar" + }, + "meta": { + "foo": "bar" + } + } + } + } + } + ', + new DataDocument( + new ResourceObject( + 'basket', + '1', + new EmptyRelationship('empty', new RelatedLink('/foo'), new SelfLink('/bar'), new Meta('foo', 'bar')) + ) + ) + ); + } + public function testCanNotCreateIdAttribute() { $this->expectException(\DomainException::class); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy