@@ -645,6 +645,25 @@ public function itParsesMeta()
645
645
static ::assertEquals (new Meta (['foo ' => 'bar ' ]), $ item ->getMeta ());
646
646
}
647
647
648
+ /**
649
+ * @test
650
+ */
651
+ public function itParsesMetaInData ()
652
+ {
653
+ $ typeMapper = new TypeMapper ();
654
+ $ typeMapper ->setMapping ('child ' , ChildItem::class);
655
+ $ typeMapper ->setMapping ('master ' , MasterItem::class);
656
+ $ parser = $ this ->getItemParser ($ typeMapper );
657
+
658
+ $ item = $ parser ->parse ($ this ->getJsonApiItemMock ('master ' , '1 ' ));
659
+
660
+ $ dataMeta = $ item ->getRelation ('childwithdatameta ' )->getIncluded ()->getDataMeta ();
661
+ static ::assertInstanceOf (Meta::class, $ dataMeta );
662
+
663
+ $ image = $ dataMeta ->imageDerivatives ->links ->header ->href ;
664
+ $ this ->assertEquals ('https://example.com/image/header/about-us.jpeg ' , $ image );
665
+ }
666
+
648
667
/**
649
668
* @param \Swis\JsonApi\Client\Interfaces\TypeMapperInterface|null $typeMapper
650
669
*
@@ -766,6 +785,30 @@ private function getJsonApiItemMock($type, $id)
766
785
'foo ' => 'bar ' ,
767
786
],
768
787
],
788
+ 'childwithdatameta ' => [
789
+ 'data ' => [
790
+ 'type ' => 'child ' ,
791
+ 'id ' => '9 ' ,
792
+ 'meta ' => [
793
+ 'alt ' => '' ,
794
+ 'width ' => 1920 ,
795
+ 'height ' => 1280 ,
796
+ 'imageDerivatives ' => [
797
+ 'links ' => [
798
+ 'header ' => [
799
+ 'href ' => 'https://example.com/image/header/about-us.jpeg ' ,
800
+ 'meta ' => [
801
+ 'rel ' => 'drupal://jsonapi/extensions/consumer_image_styles/links/relation-types/#derivative ' ,
802
+ ],
803
+ ],
804
+ ],
805
+ ],
806
+ ],
807
+ ],
808
+ 'links ' => [
809
+ 'self ' => 'http://example.com/ ' .$ type .'/ ' .$ id .'/relationships/childwithdatameta ' ,
810
+ ],
811
+ ],
769
812
'empty ' => [
770
813
'data ' => null ,
771
814
],
0 commit comments