@@ -570,39 +570,34 @@ public function testCategoryImage()
570570
571571 $ query = <<<QUERY
572572 {
573- category(id: {$ categoryId }) {
573+ categoryList(filters: {ids: {in: [" $ categoryId"]}}) {
574+ id
575+ name
576+ url_key
577+ image
578+ children {
574579 id
575580 name
576581 url_key
577582 image
578- children {
579- id
580- name
581- url_key
582- image
583- }
584583 }
584+
585+ }
585586}
586587QUERY ;
587588
588589 $ response = $ this ->graphQlQuery ($ query );
589590 $ this ->assertArrayNotHasKey ('errors ' , $ response );
590- $ this ->assertNotEmpty ($ response ['category ' ]);
591- $ category = $ response ['category ' ];
592- $ storeBaseUrl = $ this ->objectManager ->get (StoreManagerInterface::class)->getStore ()->getBaseUrl ();
593- $ expectedImageUrl = str_replace (
594- 'index.php ' ,
595- 'pub/media ' ,
596- rtrim ($ storeBaseUrl , '/ ' )
597- )
598- . '/ '
599- . ltrim ($ categoryModel ->getImage (), '/ ' );
591+ $ this ->assertNotEmpty ($ response ['categoryList ' ]);
592+ $ categoryList = $ response ['categoryList ' ];
593+ $ storeBaseUrl = $ this ->objectManager ->get (StoreManagerInterface::class)->getStore ()->getBaseUrl ('media ' );
594+ $ expectedImageUrl = rtrim ($ storeBaseUrl , '/ ' ). '/ ' . ltrim ($ categoryModel ->getImage (), '/ ' );
600595
601- $ this ->assertEquals ($ categoryId , $ category ['id ' ]);
602- $ this ->assertEquals ('Parent Image Category ' , $ category ['name ' ]);
603- $ this ->assertEquals ($ expectedImageUrl , $ category ['image ' ]);
596+ $ this ->assertEquals ($ categoryId , $ categoryList [ 0 ] ['id ' ]);
597+ $ this ->assertEquals ('Parent Image Category ' , $ categoryList [ 0 ] ['name ' ]);
598+ $ this ->assertEquals ($ expectedImageUrl , $ categoryList [ 0 ] ['image ' ]);
604599
605- $ childCategory = $ category ['children ' ][0 ];
600+ $ childCategory = $ categoryList [ 0 ] ['children ' ][0 ];
606601 $ this ->assertEquals ('Child Image Category ' , $ childCategory ['name ' ]);
607602 $ this ->assertEquals ($ expectedImageUrl , $ childCategory ['image ' ]);
608603 }
0 commit comments