From 8d535aeca320f9a2efe1e7af0c2e8d14ca4f6817 Mon Sep 17 00:00:00 2001 From: Oanh Nguyen Date: Mon, 3 Jul 2017 14:48:05 +0700 Subject: [PATCH] Add more tests --- phpunit.xml.dist | 11 ++++++++++- tests/Document/CompoundDocumentTest.php | 2 +- tests/Document/DocumentTest.php | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 307be0b..108a5fe 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -19,7 +19,7 @@ - + tests @@ -33,4 +33,13 @@ src + + + + + + + + + diff --git a/tests/Document/CompoundDocumentTest.php b/tests/Document/CompoundDocumentTest.php index a502735..854a4e5 100644 --- a/tests/Document/CompoundDocumentTest.php +++ b/tests/Document/CompoundDocumentTest.php @@ -55,7 +55,7 @@ public function testIncludedResourcesRepresentedAsArray() ) ) ); - $doc = \Lemon\JsonApi\Document::fromResource($basket); + $doc = Document::fromResource($basket); $doc->setIncluded($apple, $orange); $this->assertEquals( [ diff --git a/tests/Document/DocumentTest.php b/tests/Document/DocumentTest.php index 70017cc..d3a3f5f 100644 --- a/tests/Document/DocumentTest.php +++ b/tests/Document/DocumentTest.php @@ -111,6 +111,24 @@ public function testDocumentMayContainVersion() ); } + public function testDocumentMayResetVersion() + { + $doc = $this->createNullDoc(); + $doc->setApiMeta(['a' => 'b']); + $doc->setApiVersion('1.2.3'); + + $this->assertEqualsAsJson( + [ + 'data' => null, + 'jsonapi' => [ + 'version' => '1.2.3', + 'meta' => ['a' => 'b'], + ], + ], + $doc + ); + } + public function testDocumentMayContainLinks() { $doc = $this->createNullDoc();