File tree Expand file tree Collapse file tree 2 files changed +39
-11
lines changed
src/BusinessLogic/Domain/PromotionalWidgets/Services
tests/BusinessLogic/Domain/PromotionalWidgets/Services Expand file tree Collapse file tree 2 files changed +39
-11
lines changed Original file line number Diff line number Diff line change @@ -102,17 +102,15 @@ public function isProductSupported(string $productId): bool
102102
103103 $ productSku = $ this ->productService ->getProductsSkuByProductId ($ productId );
104104
105- if (!$ productSku ) {
106- return false ;
107- }
108-
109- $ excludedProducts = $ generalSettings ->getExcludedProducts () ?? [];
110-
111- if (
112- $ excludedProducts &&
113- in_array ($ productSku , $ excludedProducts , true )
114- ) {
115- return false ;
105+ if ($ productSku ) {
106+ $ excludedProducts = $ generalSettings ->getExcludedProducts () ?? [];
107+
108+ if (
109+ $ excludedProducts &&
110+ in_array ($ productSku , $ excludedProducts , true )
111+ ) {
112+ return false ;
113+ }
116114 }
117115
118116 $ excludedCategories = $ generalSettings ->getExcludedCategories () ?? [];
Original file line number Diff line number Diff line change @@ -280,6 +280,36 @@ public function testIsProductSupportedSkuExcluded(): void
280280 self ::assertFalse ($ result );
281281 }
282282
283+ /**
284+ * @dataProvider dataProviderIsProductSupportedEmptySku
285+ * @return void
286+ */
287+ public function testIsProductSupportedEmptySku ($ sku ): void
288+ {
289+ //arrange
290+ $ this ->mockGeneralSettingsService ->saveGeneralSettings (
291+ new GeneralSettings (
292+ true ,
293+ null ,
294+ null ,
295+ null ,
296+ null
297+ )
298+ );
299+ $ this ->mockProductService ->setMockProductSku ('' );
300+
301+ // act
302+ $ result = $ this ->widgetValidationService ->isProductSupported ($ sku );
303+
304+ // assert
305+ self ::assertTrue ($ result );
306+ }
307+
308+ public function dataProviderIsProductSupportedEmptySku (): array
309+ {
310+ return [['' ], ['0 ' ]];
311+ }
312+
283313 /**
284314 * @return void
285315 */
You can’t perform that action at this time.
0 commit comments