@@ -96,6 +96,58 @@ public function testSingleProductBrandBySlug() {
9696 $ this ->assertQuerySuccessful ( $ response , $ expected );
9797 }
9898
99+ /**
100+ * Test that productBrand image resolves from WooCommerce term thumbnail meta.
101+ */
102+ public function testProductBrandImage () {
103+ $ brand_id = $ this ->createProductBrand ( 'brand-with-image ' );
104+ $ image_id = $ this ->factory ->post ->create (
105+ [
106+ 'post_author ' => $ this ->shop_manager ,
107+ 'post_status ' => 'publish ' ,
108+ 'post_title ' => 'Brand Image ' ,
109+ 'post_type ' => 'attachment ' ,
110+ ]
111+ );
112+
113+ update_term_meta ( $ brand_id , 'thumbnail_id ' , $ image_id );
114+
115+ $ query = '
116+ query ($id: ID!) {
117+ productBrand(id: $id, idType: SLUG) {
118+ databaseId
119+ image {
120+ id
121+ }
122+ }
123+ productBrands(first: 100) {
124+ nodes {
125+ slug
126+ image {
127+ id
128+ }
129+ }
130+ }
131+ }
132+ ' ;
133+
134+ $ variables = [ 'id ' => 'brand-with-image ' ];
135+ $ response = $ this ->graphql ( compact ( 'query ' , 'variables ' ) );
136+ $ expected = [
137+ $ this ->expectedField ( 'productBrand.databaseId ' , $ brand_id ),
138+ $ this ->expectedField ( 'productBrand.image.id ' , $ this ->toRelayId ( 'post ' , $ image_id ) ),
139+ $ this ->expectedNode (
140+ 'productBrands.nodes ' ,
141+ [
142+ $ this ->expectedField ( 'slug ' , 'brand-with-image ' ),
143+ $ this ->expectedField ( 'image.id ' , $ this ->toRelayId ( 'post ' , $ image_id ) ),
144+ ]
145+ ),
146+ ];
147+
148+ $ this ->assertQuerySuccessful ( $ response , $ expected );
149+ }
150+
99151 /**
100152 * Test the connection from productBrand to products.
101153 */
0 commit comments