@@ -110,16 +110,7 @@ public function testProductListSortOrder(string $sortBy, string $direction, arra
110
110
*/
111
111
public function testProductListSortOrderWithConfig (string $ sortBy , string $ direction , array $ expectation ): void
112
112
{
113
- $ this ->objectManager ->removeSharedInstance (Config::class);
114
- $ this ->scopeConfig ->setValue (
115
- Config::XML_PATH_LIST_DEFAULT_SORT_BY ,
116
- $ sortBy ,
117
- ScopeInterface::SCOPE_STORE ,
118
- Store::DEFAULT_STORE_ID
119
- );
120
- $ category = $ this ->updateCategorySortBy ('Category 1 ' , Store::DEFAULT_STORE_ID , null );
121
- $ this ->renderBlock ($ category , $ direction );
122
- $ this ->assertBlockSorting ($ sortBy , $ expectation );
113
+ $ this ->assertProductListSortOrderWithConfig ($ sortBy , $ direction , $ expectation );
123
114
}
124
115
125
116
/**
@@ -322,4 +313,89 @@ private function updateCategorySortBy(
322
313
323
314
return $ category ;
324
315
}
316
+
317
+ /**
318
+ * Test product list ordered by price with out-of-stock configurable product options with elasticsearch engine
319
+ *
320
+ * @magentoDataFixture Magento/Catalog/_files/products_with_not_empty_layered_navigation_attribute.php
321
+ * @magentoDataFixture Magento/Framework/Search/_files/product_configurable_with_out-of-stock_child.php
322
+ * @magentoConfigFixture current_store cataloginventory/options/show_out_of_stock 1
323
+ * @magentoConfigFixture default/catalog/search/engine elasticsearch7
324
+ * @dataProvider productListWithOutOfStockSortOrderDataProvider
325
+ * @param string $sortBy
326
+ * @param string $direction
327
+ * @param array $expected
328
+ * @return void
329
+ */
330
+ public function testProductListOutOfStockSortOrderWithElasticsearch (
331
+ string $ sortBy ,
332
+ string $ direction ,
333
+ array $ expected
334
+ ): void {
335
+ $ this ->assertProductListSortOrderWithConfig ($ sortBy , $ direction , $ expected );
336
+ }
337
+
338
+ /**
339
+ * Test product list ordered by price with out-of-stock configurable product options with mysql search engine
340
+ *
341
+ * @magentoDataFixture Magento/Catalog/_files/products_with_not_empty_layered_navigation_attribute.php
342
+ * @magentoDataFixture Magento/Framework/Search/_files/product_configurable_with_out-of-stock_child.php
343
+ * @magentoConfigFixture current_store cataloginventory/options/show_out_of_stock 1
344
+ * @magentoConfigFixture default/catalog/search/engine mysql
345
+ * @dataProvider productListWithOutOfStockSortOrderDataProvider
346
+ * @param string $sortBy
347
+ * @param string $direction
348
+ * @param array $expected
349
+ * @return void
350
+ */
351
+ public function testProductListOutOfStockSortOrderWithMysql (
352
+ string $ sortBy ,
353
+ string $ direction ,
354
+ array $ expected
355
+ ): void {
356
+ $ this ->assertProductListSortOrderWithConfig ($ sortBy , $ direction , $ expected );
357
+ }
358
+
359
+ /**
360
+ * Product list with out-of-stock sort order data provider
361
+ *
362
+ * @return array
363
+ */
364
+ public function productListWithOutOfStockSortOrderDataProvider (): array
365
+ {
366
+ return [
367
+ 'default_order_price_asc ' => [
368
+ 'sort ' => 'price ' ,
369
+ 'direction ' => Collection::SORT_ORDER_ASC ,
370
+ 'expectation ' => ['simple1 ' , 'simple2 ' , 'simple3 ' , 'configurable ' ],
371
+ ],
372
+ 'default_order_price_desc ' => [
373
+ 'sort ' => 'price ' ,
374
+ 'direction ' => Collection::SORT_ORDER_DESC ,
375
+ 'expectation ' => ['simple3 ' , 'simple2 ' , 'simple1 ' , 'configurable ' ],
376
+ ],
377
+ ];
378
+ }
379
+
380
+ /**
381
+ * Assert product list order
382
+ *
383
+ * @param string $sortBy
384
+ * @param string $direction
385
+ * @param array $expected
386
+ * @return void
387
+ */
388
+ private function assertProductListSortOrderWithConfig (string $ sortBy , string $ direction , array $ expected ): void
389
+ {
390
+ $ this ->objectManager ->removeSharedInstance (Config::class);
391
+ $ this ->scopeConfig ->setValue (
392
+ Config::XML_PATH_LIST_DEFAULT_SORT_BY ,
393
+ $ sortBy ,
394
+ ScopeInterface::SCOPE_STORE ,
395
+ Store::DEFAULT_STORE_ID
396
+ );
397
+ $ category = $ this ->updateCategorySortBy ('Category 1 ' , Store::DEFAULT_STORE_ID , null );
398
+ $ this ->renderBlock ($ category , $ direction );
399
+ $ this ->assertBlockSorting ($ sortBy , $ expected );
400
+ }
325
401
}
0 commit comments