Skip to content

Commit a9d33f0

Browse files
MC-29212: Magento\LayeredNavigation\Block\Navigation\Category\SelectFilterTest.testGetFiltersWithCustomAttribute fails on nightly builds with mysql search
1 parent e3e85a1 commit a9d33f0

File tree

3 files changed

+93
-1
lines changed

3 files changed

+93
-1
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Catalog\Api\Data\ProductAttributeInterface;
9+
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
10+
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
11+
use Magento\Catalog\Setup\CategorySetup;
12+
use Magento\TestFramework\Helper\Bootstrap;
13+
14+
$objectManager = Bootstrap::getObjectManager();
15+
/** @var $attribute Attribute */
16+
$attribute = $objectManager->create(Attribute::class);
17+
/** @var ProductAttributeRepositoryInterface $attributeRepository */
18+
$attributeRepository = $objectManager->create(ProductAttributeRepositoryInterface::class);
19+
/** @var $installer CategorySetup */
20+
$installer = $objectManager->create(CategorySetup::class);
21+
$entityTypeId = $installer->getEntityTypeId(ProductAttributeInterface::ENTITY_TYPE_CODE);
22+
23+
if (!$attribute->loadByCode($entityTypeId, 'dropdown_attribute')->getId()) {
24+
$attribute->setData(
25+
[
26+
'attribute_code' => 'dropdown_attribute',
27+
'entity_type_id' => $entityTypeId,
28+
'is_global' => 0,
29+
'is_user_defined' => 1,
30+
'frontend_input' => 'select',
31+
'is_unique' => 0,
32+
'is_required' => 0,
33+
'is_searchable' => 0,
34+
'is_visible_in_advanced_search' => 0,
35+
'is_comparable' => 0,
36+
'is_filterable' => 0,
37+
'is_filterable_in_search' => 0,
38+
'is_used_for_promo_rules' => 0,
39+
'is_html_allowed_on_front' => 1,
40+
'is_visible_on_front' => 1,
41+
'used_in_product_listing' => 1,
42+
'used_for_sort_by' => 0,
43+
'frontend_label' => ['Drop-Down Attribute'],
44+
'backend_type' => 'int',
45+
'option' => [
46+
'value' => [
47+
'option_1' => ['Option 1'],
48+
'option_2' => ['Option 2'],
49+
'option_3' => ['Option 3'],
50+
],
51+
'order' => [
52+
'option_1' => 1,
53+
'option_2' => 2,
54+
'option_3' => 3,
55+
],
56+
],
57+
]
58+
);
59+
$attributeRepository->save($attribute);
60+
/* Assign attribute to attribute set */
61+
$installer->addAttributeToGroup(
62+
ProductAttributeInterface::ENTITY_TYPE_CODE,
63+
'Default',
64+
'Attributes',
65+
$attribute->getId()
66+
);
67+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Framework\Exception\NoSuchEntityException;
9+
use Magento\TestFramework\Helper\Bootstrap;
10+
use Magento\Framework\Registry;
11+
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
12+
13+
$objectManager = Bootstrap::getObjectManager();
14+
$registry = $objectManager->get(Registry::class);
15+
$registry->unregister('isSecureArea');
16+
$registry->register('isSecureArea', true);
17+
/** @var ProductAttributeRepositoryInterface $attributeRepository */
18+
$attributeRepository = $objectManager->create(ProductAttributeRepositoryInterface::class);
19+
20+
try {
21+
$attributeRepository->deleteById('dropdown_attribute');
22+
} catch (NoSuchEntityException $e) {
23+
}
24+
$registry->unregister('isSecureArea');
25+
$registry->register('isSecureArea', false);

dev/tests/integration/testsuite/Magento/LayeredNavigation/Block/Navigation/Category/SelectFilterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class SelectFilterTest extends AbstractFiltersTest
2020
{
2121
/**
22-
* @magentoDataFixture Magento/Catalog/_files/dropdown_attribute.php
22+
* @magentoDataFixture Magento/Catalog/_files/product_dropdown_attribute.php
2323
* @magentoDataFixture Magento/Catalog/_files/category_with_different_price_products.php
2424
* @dataProvider getFiltersWithCustomAttributeDataProvider
2525
* @param array $products

0 commit comments

Comments
 (0)