Skip to content

Commit d0c92dd

Browse files
author
Roman Hanin
committed
Merge branch '2.4-develop' of https://github.com/magento/magento2ce into B2B-2424
2 parents c07326f + 24a2c46 commit d0c92dd

File tree

20 files changed

+315
-79
lines changed

20 files changed

+315
-79
lines changed

app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryMainSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,7 @@
4141
<element name="productNameByPosition" type="text" selector=".products-grid li:nth-of-type({{position}}) .product-item-name a" parameterized="true"/>
4242
<element name="sidebarAdditional" type="block" selector="#maincontent .sidebar.sidebar-additional"/>
4343
<element name="searchStore" type="input" selector="//div/input[@id='search']" />
44+
<element name="productAttributeName" type="button" selector="//div[@class='filter-options-title' and contains(text(),'{{var1}}')]" parameterized="true"/>
45+
<element name="productAttributeOptionValue" type="button" selector="//div[@id='narrow-by-list']//a[contains(text(), '{{var1}}')]" parameterized="true"/>
4446
</section>
4547
</sections>

app/code/Magento/Cms/Block/Page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ protected function _addBreadcrumbs(\Magento\Cms\Model\Page $page)
135135
'web/default/cms_no_route',
136136
ScopeInterface::SCOPE_STORE
137137
);
138-
$noRouteDelimiterPosition = strrpos($noRouteIdentifier, '|');
138+
$noRouteDelimiterPosition = $noRouteIdentifier === null ? false : strrpos($noRouteIdentifier, '|');
139139
if ($noRouteDelimiterPosition) {
140140
$noRouteIdentifier = substr($noRouteIdentifier, 0, $noRouteDelimiterPosition);
141141
}

app/code/Magento/Elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchResultApplier.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ private function categoryProductByCustomSortOrder(int $categoryId): array
211211
$searchCriteria = $this->searchResult->getSearchCriteria();
212212
$sortOrders = $searchCriteria->getSortOrders() ?? [];
213213
$sortOrders = array_merge(['is_salable' => \Magento\Framework\DB\Select::SQL_DESC], $sortOrders);
214-
215214
$connection = $this->collection->getConnection();
216215
$query = clone $connection->select()
217216
->reset(\Magento\Framework\DB\Select::ORDER)
@@ -231,6 +230,14 @@ private function categoryProductByCustomSortOrder(int $categoryId): array
231230
. ' AND cat_index.store_id = ' . $storeId,
232231
['cat_index.position']
233232
);
233+
234+
$productIds = [];
235+
foreach ($this->searchResult->getItems() as $item) {
236+
$productIds[] = $item->getId();
237+
}
238+
239+
$query->where('e.entity_id IN(?)', $productIds);
240+
234241
foreach ($sortOrders as $field => $dir) {
235242
if ($field === 'name') {
236243
$entityTypeId = $this->collection->getEntity()->getTypeId();
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StoreFrontSearchWithProductAttributeOptionValue">
12+
<annotations>
13+
<stories value="Store front search product when display out of stock products to yes"/>
14+
<title value="Catalog shown entire catalog items count if show_of_stock_option enabled"/>
15+
<description value="Catalog shown entire catalog items count if show_of_stock_option enabled"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="AC-6395"/>
18+
<group value="catalog_search"/>
19+
</annotations>
20+
<before>
21+
<magentoCLI command="config:set cataloginventory/options/show_out_of_stock 1" stepKey="setOutOfStockToYes"/>
22+
<magentoCLI command="cache:clean config" stepKey="cacheClean"/>
23+
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
24+
25+
<createData entity="_defaultCategory" stepKey="createCategory"/>
26+
<createData entity="SimpleProduct" stepKey="createProduct01">
27+
<requiredEntity createDataKey="createCategory"/>
28+
</createData>
29+
30+
<createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/>
31+
<createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1">
32+
<requiredEntity createDataKey="createConfigProductAttribute"/>
33+
</createData>
34+
<createData entity="productAttributeOption2" stepKey="createConfigProductAttributeOption2">
35+
<requiredEntity createDataKey="createConfigProductAttribute"/>
36+
</createData>
37+
<createData entity="AddToDefaultSet" stepKey="createConfigAddToAttributeSet">
38+
<requiredEntity createDataKey="createConfigProductAttribute"/>
39+
</createData>
40+
41+
<createData entity="SimpleProduct" stepKey="createProduct02">
42+
<requiredEntity createDataKey="createCategory"/>
43+
</createData>
44+
45+
<createData entity="AssignProductToCategory" stepKey="assignTestCategoryToTestProduct">
46+
<requiredEntity createDataKey="createCategory"/>
47+
<requiredEntity createDataKey="createProduct01"/>
48+
<requiredEntity createDataKey="createProduct02"/>
49+
</createData>
50+
</before>
51+
<after>
52+
<magentoCLI command="config:set cataloginventory/options/show_out_of_stock 0" stepKey="setOutOfStockToNo"/>
53+
<deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/>
54+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
55+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
56+
<deleteData createDataKey="createProduct01" stepKey="deleteProduct1"/>
57+
<deleteData createDataKey="createProduct02" stepKey="deleteProduct2"/>
58+
</after>
59+
60+
<amOnPage url="{{StorefrontCategoryPage.url($$createCategory.custom_attributes[url_key]$$)}}" stepKey="goToStorefrontCreatedCategoryPage"/>
61+
<click selector="{{StorefrontCategoryMainSection.productAttributeName('attribute')}}" stepKey="selectProductAttribute"/>
62+
<wait time="2" stepKey="waitForLoad"/>
63+
<click selector="{{StorefrontCategoryMainSection.productAttributeOptionValue('option')}}" stepKey="selectProductAttributeOptionValue"/>
64+
</test>
65+
</tests>

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"colinmollenhour/cache-backend-file": "~1.4.1",
3838
"colinmollenhour/cache-backend-redis": "1.14.2",
3939
"colinmollenhour/credis": "1.13.0",
40-
"colinmollenhour/php-redis-session-abstract": "~1.4.5",
40+
"colinmollenhour/php-redis-session-abstract": "v1.5.0",
4141
"composer/composer": "^1.9 || ^2.0, !=2.2.16",
4242
"elasticsearch/elasticsearch": "~7.17.0",
4343
"ezyang/htmlpurifier": "^4.14",

composer.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddSimpleProductToCartSingleMutationTest.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;
1212
use Magento\Quote\Test\Fixture\AddProductToCart as AddProductToCartFixture;
1313
use Magento\Quote\Test\Fixture\GuestCart as GuestCartFixture;
14+
use Magento\Store\Test\Fixture\Group as StoreGroupFixture;
15+
use Magento\Store\Test\Fixture\Store as StoreFixture;
16+
use Magento\Store\Test\Fixture\Website as WebsiteFixture;
1417
use Magento\TestFramework\Fixture\DataFixture;
1518
use Magento\TestFramework\Fixture\DataFixtureStorage;
1619
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
@@ -219,18 +222,27 @@ public function testAddProductWithWrongQuantity(int $quantity, string $message)
219222
}
220223

221224
/**
222-
* @magentoApiDataFixture Magento/Catalog/_files/products_with_websites_and_stores.php
223-
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
224-
* @magentoApiDataFixture Magento/Checkout/_files/active_quote_not_default_website.php
225225
* @dataProvider addProductNotAssignedToWebsiteDataProvider
226-
* @param string $reservedOrderId
227-
* @param string $sku
226+
* @param string $cart
227+
* @param string $product
228228
* @param array $headerMap
229229
*/
230-
public function testAddProductNotAssignedToWebsite(string $reservedOrderId, string $sku, array $headerMap)
230+
#[
231+
DataFixture(WebsiteFixture::class, as: 'website2'),
232+
DataFixture(StoreGroupFixture::class, ['website_id' => '$website2.id$'], 'store_group2'),
233+
DataFixture(StoreFixture::class, ['store_group_id' => '$store_group2.id$'], 'store2'),
234+
DataFixture(ProductFixture::class, ['website_ids' => [1]], as: 'product1'),
235+
DataFixture(ProductFixture::class, ['website_ids' => ['$website2.id$']], as: 'product2'),
236+
DataFixture(GuestCartFixture::class, as: 'cart1'),
237+
DataFixture(GuestCartFixture::class, as: 'cart2', scope: 'store2'),
238+
]
239+
public function testAddProductNotAssignedToWebsite(string $cart, string $product, array $headerMap)
231240
{
232-
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($reservedOrderId);
241+
$sku = $this->fixtures->get($product)->getSku();
242+
$cartId = (int) $this->fixtures->get($cart)->getId();
243+
$maskedQuoteId = $this->quoteIdToMaskedQuoteIdInterface->execute($cartId);
233244
$query = $this->getAddToCartMutation($maskedQuoteId, 1, $sku);
245+
$headerMap = array_map(fn ($store) => $this->fixtures->get($store)?->getCode() ?? $store, $headerMap);
234246
$response = $this->graphQlMutation($query, [], '', $headerMap);
235247
self::assertEmpty($response['addProductsToCart']['cart']['items']);
236248
self::assertArrayHasKey('user_errors', $response['addProductsToCart']);
@@ -386,9 +398,9 @@ public function testAddMultipleProductsWithInsufficientStockToEmptyCart(): void
386398
public function addProductNotAssignedToWebsiteDataProvider(): array
387399
{
388400
return [
389-
['test_order_1', 'simple-2', []],
390-
['test_order_1', 'simple-2', ['Store' => 'default']],
391-
['test_order_2', 'simple-1', ['Store' => 'fixture_second_store']],
401+
['cart1', 'product2', []],
402+
['cart1', 'product2', ['Store' => 'default']],
403+
['cart2', 'product1', ['Store' => 'store2']],
392404
];
393405
}
394406

dev/tests/integration/framework/Magento/TestFramework/Annotation/DataFixtureSetup.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,23 @@
1313
use Magento\TestFramework\Fixture\DataFixtureFactory;
1414
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
1515
use Magento\TestFramework\Fixture\RevertibleDataFixtureInterface;
16+
use Magento\TestFramework\ScopeSwitcherInterface;
1617

1718
/**
1819
* Apply and revert data fixtures
1920
*/
2021
class DataFixtureSetup
2122
{
22-
/**
23-
* @var Registry
24-
*/
25-
private $registry;
26-
27-
/**
28-
* @var DataFixtureFactory
29-
*/
30-
private $dataFixtureFactory;
31-
3223
/**
3324
* @param Registry $registry
3425
* @param DataFixtureFactory $dataFixtureFactory
26+
* @param ScopeSwitcherInterface $scopeSwitcher
3527
*/
3628
public function __construct(
37-
Registry $registry,
38-
DataFixtureFactory $dataFixtureFactory
29+
private Registry $registry,
30+
private DataFixtureFactory $dataFixtureFactory,
31+
private ScopeSwitcherInterface $scopeSwitcher
3932
) {
40-
$this->registry = $registry;
41-
$this->dataFixtureFactory = $dataFixtureFactory;
4233
}
4334

4435
/**
@@ -51,7 +42,17 @@ public function apply(array $fixture): ?DataObject
5142
{
5243
$data = $this->resolveVariables($fixture['data'] ?? []);
5344
$factory = $this->dataFixtureFactory->create($fixture['factory']);
54-
$result = $factory->apply($data);
45+
if (isset($fixture['scope'])) {
46+
$scope = DataFixtureStorageManager::getStorage()->get($fixture['scope']);
47+
$fromScope = $this->scopeSwitcher->switch($scope);
48+
try {
49+
$result = $factory->apply($data);
50+
} finally {
51+
$this->scopeSwitcher->switch($fromScope);
52+
}
53+
} else {
54+
$result = $factory->apply($data);
55+
}
5556

5657
if ($result !== null && !empty($fixture['name'])) {
5758
DataFixtureStorageManager::getStorage()->persist(

dev/tests/integration/framework/Magento/TestFramework/Fixture/DataFixture.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@
1313
class DataFixture
1414
{
1515
/**
16-
* @param string $type
17-
* @param array $data
18-
* @param string|null $as
16+
* @param string $type Fixture class name
17+
* @param array $data Data passed on to the fixture.
18+
* @param string|null $as Fixture identifier used to retrieve the data returned by the fixture
19+
* @param string|null $scope Name of scope data fixture in which the data fixture should be executed
20+
* @param int $count Number of instances to generate
1921
*/
2022
public function __construct(
2123
public string $type,
2224
public array $data = [],
23-
public ?string $as = null
25+
public ?string $as = null,
26+
public ?string $scope = null,
27+
public int $count = 1
2428
) {
2529
}
2630
}

dev/tests/integration/framework/Magento/TestFramework/Fixture/Parser/DataFixture.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public function __construct(
3535
*/
3636
public function parse(TestCase $test, string $scope): array
3737
{
38-
$fixtures = [];
3938
try {
4039
$reflection = $scope === ParserInterface::SCOPE_CLASS
4140
? new \ReflectionClass($test)
@@ -50,14 +49,22 @@ public function parse(TestCase $test, string $scope): array
5049
);
5150
}
5251

52+
$fixtures = [];
5353
$attributes = $reflection->getAttributes($this->attributeClass);
5454
foreach ($attributes as $attribute) {
5555
$args = $attribute->getArguments();
56-
$fixtures[] = [
57-
'name' => $args['as'] ?? $args[2] ?? null,
58-
'factory' => $args[0],
59-
'data' => $args[1] ?? [],
60-
];
56+
$alias = $args['as'] ?? $args[2] ?? null;
57+
$count = $args['count'] ?? $args[4] ?? 1;
58+
$id = $count > 1 ? 1 : '';
59+
do {
60+
$fixtures[] = [
61+
'name' => $alias !== null ? ($alias.($id++)) : null,
62+
'factory' => $args[0],
63+
'data' => $args[1] ?? [],
64+
'scope' => $args['scope'] ?? $args[3] ?? null,
65+
];
66+
} while (--$count > 0);
67+
6168
}
6269
return $fixtures;
6370
}

0 commit comments

Comments
 (0)