@@ -36,7 +36,8 @@ public function let(
36
36
): void {
37
37
$ ecommerceOrderProductFactory ->createNew ('Wine bottle ' , 1200 , 2 , '432 ' )->willReturn ($ ecommerceOrderProduct );
38
38
39
- $ channelHostnameUrlGenerator ->generate ($ channel , 'sylius_shop_product_show ' , ['_locale ' => 'it_IT ' , 'slug ' => 'wine-bottle ' ])->willReturn ('https://localhost/products/wine-bottle ' );
39
+ $ channelHostnameUrlGenerator ->generateForRoute ($ channel , 'sylius_shop_product_show ' , ['_locale ' => 'it_IT ' , 'slug ' => 'wine-bottle ' ])->willReturn ('https://localhost/products/wine-bottle ' );
40
+ $ channelHostnameUrlGenerator ->generateForImage ($ channel , 'path/wine.png ' , null )->willReturn ('https://domain.org/media/image/path/wine.png ' );
40
41
41
42
$ frenchLocale ->getCode ()->willReturn ('fr_FR ' );
42
43
@@ -69,7 +70,7 @@ public function let(
69
70
$ ecommerceOrderProduct ->setImageUrl ('https://domain.org/media/image/path/wine.png ' );
70
71
$ ecommerceOrderProduct ->setProductUrl ('https://localhost/products/wine-bottle ' );
71
72
72
- $ this ->beConstructedWith ($ ecommerceOrderProductFactory , $ channelHostnameUrlGenerator , 'en_US ' , ' https ' , null );
73
+ $ this ->beConstructedWith ($ ecommerceOrderProductFactory , $ channelHostnameUrlGenerator , 'en_US ' , null , null );
73
74
}
74
75
75
76
public function it_is_initializable (): void
@@ -117,13 +118,6 @@ public function it_throws_if_order_item_order_channel_is_null(OrderItemInterface
117
118
->during ('mapFromOrderItem ' , [$ orderItem ]);
118
119
}
119
120
120
- public function it_throws_if_order_item_order_channel_hostname_is_null (OrderItemInterface $ orderItem , ChannelInterface $ channel ): void
121
- {
122
- $ channel ->getHostname ()->willReturn (null );
123
- $ this ->shouldThrow (new InvalidArgumentException ('The channel \'s hostname should not be null. ' ))
124
- ->during ('mapFromOrderItem ' , [$ orderItem ]);
125
- }
126
-
127
121
public function it_maps_ecommerce_order_product_without_category_if_main_taxon_does_not_exist (
128
122
OrderItemInterface $ orderItem ,
129
123
ProductInterface $ product ,
@@ -154,8 +148,9 @@ public function it_maps_ecommerce_order_product_without_image_url_if_products_do
154
148
ProductInterface $ product ,
155
149
EcommerceOrderProductInterface $ ecommerceOrderProduct
156
150
): void {
157
- $ this ->beConstructedWith ($ ecommerceOrderProductFactory , $ channelHostnameUrlGenerator , 'en_US ' , 'https ' , ' main ' );
151
+ $ this ->beConstructedWith ($ ecommerceOrderProductFactory , $ channelHostnameUrlGenerator , 'en_US ' , 'main ' );
158
152
$ product ->getImagesByType ('main ' )->willReturn (new ArrayCollection ());
153
+ $ product ->getImages ()->willReturn (new ArrayCollection ());
159
154
$ ecommerceOrderProduct ->setImageUrl ('media/image/path/wine.png ' )->shouldNotBeCalled ();
160
155
$ ecommerceOrderProduct ->setImageUrl (null )->shouldBeCalledOnce ();
161
156
@@ -168,11 +163,13 @@ public function it_maps_ecommerce_order_product_with_image_url_from_specified_ty
168
163
OrderItemInterface $ orderItem ,
169
164
ProductInterface $ product ,
170
165
EcommerceOrderProductInterface $ ecommerceOrderProduct ,
171
- ImageInterface $ typedImage
166
+ ImageInterface $ typedImage ,
167
+ ChannelInterface $ channel ,
172
168
): void {
173
- $ this ->beConstructedWith ($ ecommerceOrderProductFactory , $ channelHostnameUrlGenerator , 'en_US ' , 'https ' , ' main ' );
169
+ $ this ->beConstructedWith ($ ecommerceOrderProductFactory , $ channelHostnameUrlGenerator , 'en_US ' , 'main ' );
174
170
$ product ->getImagesByType ('main ' )->willReturn (new ArrayCollection ([$ typedImage ->getWrappedObject ()]));
175
171
$ typedImage ->getPath ()->willReturn ('path/main.jpg ' );
172
+ $ channelHostnameUrlGenerator ->generateForImage ($ channel , 'path/main.jpg ' , null )->willReturn ('https://domain.org/media/image/path/main.jpg ' );
176
173
$ ecommerceOrderProduct ->setImageUrl ('https://domain.org/media/image/path/wine.png ' )->shouldNotBeCalled ();
177
174
$ ecommerceOrderProduct ->setImageUrl (null )->shouldNotBeCalled ();
178
175
$ ecommerceOrderProduct ->setImageUrl ('https://domain.org/media/image/path/main.jpg ' )->shouldBeCalledOnce ();
@@ -187,7 +184,7 @@ public function it_maps_ecommerce_order_product_without_image_url_from_specified
187
184
ProductInterface $ product ,
188
185
EcommerceOrderProductInterface $ ecommerceOrderProduct
189
186
): void {
190
- $ this ->beConstructedWith ($ ecommerceOrderProductFactory , $ channelHostnameUrlGenerator , 'en_US ' , 'https ' , ' ' );
187
+ $ this ->beConstructedWith ($ ecommerceOrderProductFactory , $ channelHostnameUrlGenerator , 'en_US ' , '' );
191
188
$ product ->getImagesByType ('' )->shouldNotBeCalled ();
192
189
$ ecommerceOrderProduct ->setImageUrl ('https://domain.org/media/image/path/wine.png ' )->shouldBeCalledOnce ();
193
190
$ ecommerceOrderProduct ->setImageUrl (null )->shouldNotBeCalled ();
@@ -203,7 +200,7 @@ public function it_maps_ecommerce_order_product_with_default_channel_locale_if_n
203
200
EcommerceOrderProductInterface $ ecommerceOrderProduct
204
201
): void {
205
202
$ order ->getLocaleCode ()->willReturn (null );
206
- $ channelHostnameUrlGenerator ->generate ($ channel , 'sylius_shop_product_show ' , ['_locale ' => 'fr_FR ' , 'slug ' => 'wine-bottle ' ])->shouldBeCalledOnce ()->willReturn ('https://localhost/products/wine-bottle ' );
203
+ $ channelHostnameUrlGenerator ->generateForRoute ($ channel , 'sylius_shop_product_show ' , ['_locale ' => 'fr_FR ' , 'slug ' => 'wine-bottle ' ])->shouldBeCalledOnce ()->willReturn ('https://localhost/products/wine-bottle ' );
207
204
208
205
$ this ->mapFromOrderItem ($ orderItem )->shouldReturn ($ ecommerceOrderProduct );
209
206
}
@@ -217,7 +214,7 @@ public function it_maps_ecommerce_order_product_with_default_app_locale_if_not_e
217
214
): void {
218
215
$ order ->getLocaleCode ()->willReturn (null );
219
216
$ channel ->getDefaultLocale ()->willReturn (null );
220
- $ channelHostnameUrlGenerator ->generate ($ channel , 'sylius_shop_product_show ' , ['_locale ' => 'en_US ' , 'slug ' => 'wine-bottle ' ])->shouldBeCalledOnce ()->willReturn ('https://localhost/products/wine-bottle ' );
217
+ $ channelHostnameUrlGenerator ->generateForRoute ($ channel , 'sylius_shop_product_show ' , ['_locale ' => 'en_US ' , 'slug ' => 'wine-bottle ' ])->shouldBeCalledOnce ()->willReturn ('https://localhost/products/wine-bottle ' );
221
218
222
219
$ this ->mapFromOrderItem ($ orderItem )->shouldReturn ($ ecommerceOrderProduct );
223
220
}
@@ -232,7 +229,7 @@ public function it_maps_ecommerce_order_product_with_default_app_locale_if_not_e
232
229
): void {
233
230
$ order ->getLocaleCode ()->willReturn (null );
234
231
$ frenchLocale ->getCode ()->willReturn (null );
235
- $ channelHostnameUrlGenerator ->generate ($ channel , 'sylius_shop_product_show ' , ['_locale ' => 'en_US ' , 'slug ' => 'wine-bottle ' ])->shouldBeCalledOnce ()->willReturn ('https://localhost/products/wine-bottle ' );
232
+ $ channelHostnameUrlGenerator ->generateForRoute ($ channel , 'sylius_shop_product_show ' , ['_locale ' => 'en_US ' , 'slug ' => 'wine-bottle ' ])->shouldBeCalledOnce ()->willReturn ('https://localhost/products/wine-bottle ' );
236
233
237
234
$ this ->mapFromOrderItem ($ orderItem )->shouldReturn ($ ecommerceOrderProduct );
238
235
}
0 commit comments