Skip to content

Commit 9be29e3

Browse files
committed
Added simple resource identifier test
1 parent c58e9b5 commit 9be29e3

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"data": {
3+
"type": "articles",
4+
"id": "1"
5+
}
6+
}

tests/integration/IntegrationTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,28 @@ public function testParseSimpleResource()
4545
$this->assertTrue($resource->hasRelationships());
4646
$this->assertInstanceOf('Art4\JsonApiClient\RelationshipCollection', $resource->getRelationships());
4747
}
48+
49+
/**
50+
* @test parse() with valid JSON API returns Document Object
51+
*/
52+
public function testParseSimpleResourceIdentifier()
53+
{
54+
$string = $this->getJsonString('02_simple_resource_identifier.js');
55+
$document = Helper::parse($string);
56+
57+
$this->assertInstanceOf('Art4\JsonApiClient\Document', $document);
58+
$this->assertFalse($document->hasErrors());
59+
$this->assertFalse($document->hasMeta());
60+
$this->assertFalse($document->hasJsonapi());
61+
$this->assertFalse($document->hasLinks());
62+
$this->assertFalse($document->hasIncluded());
63+
$this->assertTrue($document->hasData());
64+
65+
$resource = $document->getData();
66+
67+
$this->assertInstanceOf('Art4\JsonApiClient\ResourceIdentifier', $resource);
68+
$this->assertFalse($resource->hasMeta());
69+
$this->assertSame($resource->getType(), 'articles');
70+
$this->assertSame($resource->getId(), '1');
71+
}
4872
}

0 commit comments

Comments
 (0)