File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "data" : {
3
+ "type" : "articles" ,
4
+ "id" : "1"
5
+ }
6
+ }
Original file line number Diff line number Diff line change @@ -45,4 +45,28 @@ public function testParseSimpleResource()
45
45
$ this ->assertTrue ($ resource ->hasRelationships ());
46
46
$ this ->assertInstanceOf ('Art4\JsonApiClient\RelationshipCollection ' , $ resource ->getRelationships ());
47
47
}
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
+ }
48
72
}
You can’t perform that action at this time.
0 commit comments