File tree Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Original file line number Diff line number Diff line change 44
55use Swis \JsonApi \Client \Collection ;
66use Swis \JsonApi \Client \Item ;
7+ use Swis \JsonApi \Client \Link ;
8+ use Swis \JsonApi \Client \Links ;
9+ use Swis \JsonApi \Client \Meta ;
710use Swis \JsonApi \Client \Tests \Mocks \Items \RelatedItem ;
811use Swis \JsonApi \Client \Tests \Mocks \Items \WithGetMutatorItem ;
912use Swis \JsonApi \Client \Tests \Mocks \Items \WithHiddenItem ;
@@ -372,4 +375,66 @@ public function is_adds_empty_morphtomany_relation_in_to_json_api_array()
372375 $ item ->toJsonApiArray ()
373376 );
374377 }
378+
379+ /**
380+ * @test
381+ */
382+ public function is_adds_links_in_to_json_api_array ()
383+ {
384+ $ item = new Item ();
385+ $ item ->setType ('testType ' );
386+ $ item ->setId (1 );
387+ $ item ->setLinks (
388+ new Links (
389+ [
390+ 'self ' => new Link (
391+ 'http://example.com/testType/1 ' ,
392+ new Meta (['foo ' => 'bar ' ])
393+ ),
394+ 'other ' => new Link ('http://example.com/testType/1/other ' ),
395+ ]
396+ )
397+ );
398+
399+ $ this ->assertEquals (
400+ [
401+ 'type ' => 'testType ' ,
402+ 'id ' => 1 ,
403+ 'links ' => [
404+ 'self ' => [
405+ 'href ' => 'http://example.com/testType/1 ' ,
406+ 'meta ' => [
407+ 'foo ' => 'bar ' ,
408+ ],
409+ ],
410+ 'other ' => [
411+ 'href ' => 'http://example.com/testType/1/other ' ,
412+ ],
413+ ],
414+ ],
415+ $ item ->toJsonApiArray ()
416+ );
417+ }
418+
419+ /**
420+ * @test
421+ */
422+ public function is_adds_meta_in_to_json_api_array ()
423+ {
424+ $ item = new Item ();
425+ $ item ->setType ('testType ' );
426+ $ item ->setId (1 );
427+ $ item ->setMeta (new Meta (['foo ' => 'bar ' ]));
428+
429+ $ this ->assertEquals (
430+ [
431+ 'type ' => 'testType ' ,
432+ 'id ' => 1 ,
433+ 'meta ' => [
434+ 'foo ' => 'bar ' ,
435+ ],
436+ ],
437+ $ item ->toJsonApiArray ()
438+ );
439+ }
375440}
You can’t perform that action at this time.
0 commit comments