Skip to content

Commit dd93eb3

Browse files
committed
Deliver catalog storefront tests changes to mainline
1 parent 91bead5 commit dd93eb3

19 files changed

+569
-454
lines changed

dev/tests/integration/testsuite/Magento/Catalog/_files/category_product_rollback.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@
2222
if ($category->getId()) {
2323
$category->delete();
2424
}
25+
$registry->unregister('isSecureArea');
26+
$registry->register('isSecureArea', false);

dev/tests/integration/testsuite/Magento/Catalog/_files/configurable_products_with_custom_attribute_layered_navigation.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
*/
66
declare(strict_types=1);
77

8-
use Magento\Eav\Api\AttributeRepositoryInterface;
8+
Resolver::getInstance()->requireDataFixture('Magento/ConfigurableProduct/_files/configurable_products.php');
9+
910
use Magento\TestFramework\Helper\Bootstrap;
11+
use Magento\Eav\Api\AttributeRepositoryInterface;
1012
use Magento\TestFramework\Helper\CacheCleaner;
11-
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
12-
13-
Resolver::getInstance()->requireDataFixture('Magento/ConfigurableProduct/_files/configurable_products.php');
1413

1514
$eavConfig = Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class);
1615

@@ -28,11 +27,11 @@
2827
/** @var AttributeRepositoryInterface $attributeRepository */
2928
$attributeRepository = Bootstrap::getObjectManager()->create(AttributeRepositoryInterface::class);
3029
$attributeRepository->save($attribute);
30+
3131
CacheCleaner::cleanAll();
32-
/** @var \Magento\Indexer\Model\Indexer\Collection $indexerCollection */
33-
$indexerCollection = Bootstrap::getObjectManager()->get(\Magento\Indexer\Model\Indexer\Collection::class);
34-
$indexerCollection->load();
35-
/** @var \Magento\Indexer\Model\Indexer $indexer */
36-
foreach ($indexerCollection->getItems() as $indexer) {
37-
$indexer->reindexAll();
38-
}
32+
33+
// Run from CLI due to some classes involved in reindex process have state which do not allow to reindex
34+
$appDir = dirname(Bootstrap::getInstance()->getAppTempDir());
35+
$out = '';
36+
// phpcs:ignore Magento2.Security.InsecureFunction
37+
exec("php -f {$appDir}/bin/magento indexer:reindex catalogsearch_fulltext", $out);

dev/tests/integration/testsuite/Magento/Catalog/_files/multiple_products.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
->setName('Simple Product1')
1414
->setSku('simple1')
1515
->setTaxClassId('none')
16-
->setDescription('description')
16+
->setDescription('description uniqueword')
1717
->setShortDescription('short description')
1818
->setOptionsContainer('container1')
1919
->setMsrpDisplayActualPriceType(\Magento\Msrp\Model\Product\Attribute\Source\Type::TYPE_IN_CART)

dev/tests/integration/testsuite/Magento/Catalog/_files/products_for_relevance_sorting_rollback.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
8+
9+
Resolver::getInstance()->requireDataFixture('Magento/Framework/Search/_files/products_rollback.php');
10+
711
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
812
/** @var \Magento\Framework\Registry $registry */
913
$registry = $objectManager->get(\Magento\Framework\Registry::class);

dev/tests/integration/testsuite/Magento/Catalog/_files/products_list.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
3030
->create(\Magento\Catalog\Model\Product::class);
3131
$product
32+
->setId(153)
3233
->setTypeId('simple')
3334
->setAttributeSetId(4)
3435
->setWebsiteIds([1])
@@ -49,6 +50,7 @@
4950
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
5051
->create(\Magento\Catalog\Model\Product::class);
5152
$product
53+
->setId(156)
5254
->setTypeId('simple')
5355
->setAttributeSetId(4)
5456
->setWebsiteIds([1])

dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_layered_navigation_attribute.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\TestFramework\Helper\Bootstrap;
99
use Magento\Eav\Api\AttributeRepositoryInterface;
10+
use Magento\TestFramework\Helper\CacheCleaner;
1011

1112
$eavConfig = Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class);
1213
$attribute = $eavConfig->getAttribute('catalog_product', 'test_configurable');
@@ -59,6 +60,7 @@
5960

6061
/* Assign attribute to attribute set */
6162
$installer->addAttributeToGroup('catalog_product', 'Default', 'General', $attribute->getId());
63+
CacheCleaner::cleanAll();
6264
}
6365

6466
$eavConfig->clear();

dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_layered_navigation_custom_attribute.php

Lines changed: 101 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -5,113 +5,127 @@
55
*/
66
declare(strict_types=1);
77

8-
use Magento\Catalog\Api\ProductRepositoryInterface;
9-
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
10-
use Magento\Catalog\Setup\CategorySetup;
11-
use Magento\Eav\Model\Config;
12-
use Magento\Framework\Exception\NoSuchEntityException;
13-
use Magento\Indexer\Model\Indexer;
14-
use Magento\Indexer\Model\Indexer\Collection as IndexerCollection;
158
use Magento\TestFramework\Helper\Bootstrap;
169
use Magento\Eav\Api\AttributeRepositoryInterface;
10+
use Magento\TestFramework\Helper\CacheCleaner;
1711
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
18-
use Magento\TestFramework\Eav\Model\GetAttributeSetByName;
1912

2013
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/attribute_set_based_on_default_set.php');
2114
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/categories.php');
2215

23-
$objectManager = Bootstrap::getObjectManager();
24-
/** @var GetAttributeSetByName $getAttributeSetByName */
25-
$getAttributeSetByName = $objectManager->get(GetAttributeSetByName::class);
26-
$attributeSet = $getAttributeSetByName->execute('second_attribute_set');
27-
/** @var Config $eavConfig */
28-
$eavConfig = $objectManager->get(Config::class);
29-
/** @var AttributeRepositoryInterface $attributeRepository */
30-
$attributeRepository = $objectManager->create(AttributeRepositoryInterface::class);
31-
/** @var CategorySetup $installer */
32-
$installer = $objectManager->create(CategorySetup::class);
16+
$eavConfig = Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class);
17+
$attribute = $eavConfig->getAttribute('catalog_product', 'test_configurable');
18+
3319
$eavConfig->clear();
3420

35-
$attribute = $eavConfig->getAttribute('catalog_product', 'test_configurable');
21+
$attribute1 = $eavConfig->getAttribute('catalog_product', ' second_test_configurable');
22+
$eavConfig->clear();
23+
24+
/** @var $installer \Magento\Catalog\Setup\CategorySetup */
25+
$installer = Bootstrap::getObjectManager()->create(\Magento\Catalog\Setup\CategorySetup::class);
26+
3627
if (!$attribute->getId()) {
37-
/** @var $attribute Attribute */
38-
$attribute->setData([
39-
'attribute_code' => 'test_configurable',
40-
'entity_type_id' => $installer->getEntityTypeId('catalog_product'),
41-
'is_global' => 1,
42-
'is_user_defined' => 1,
43-
'frontend_input' => 'select',
44-
'is_unique' => 0,
45-
'is_required' => 0,
46-
'is_searchable' => 0,
47-
'is_visible_in_advanced_search' => 0,
48-
'is_comparable' => 1,
49-
'is_filterable' => 1,
50-
'is_filterable_in_search' => 1,
51-
'is_used_for_promo_rules' => 0,
52-
'is_html_allowed_on_front' => 1,
53-
'is_visible_on_front' => 1,
54-
'used_in_product_listing' => 1,
55-
'used_for_sort_by' => 1,
56-
'frontend_label' => ['Test Configurable'],
57-
'backend_type' => 'int',
58-
'option' => [
59-
'value' => ['option_0' => ['Option 1'], 'option_1' => ['Option 2']],
60-
'order' => ['option_0' => 1, 'option_1' => 2],
61-
],
62-
'default_value' => 'option_0'
63-
]);
28+
29+
/** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
30+
$attribute = Bootstrap::getObjectManager()->create(
31+
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
32+
);
33+
34+
/** @var AttributeRepositoryInterface $attributeRepository */
35+
$attributeRepository = Bootstrap::getObjectManager()->create(AttributeRepositoryInterface::class);
36+
37+
$attribute->setData(
38+
[
39+
'attribute_code' => 'test_configurable',
40+
'entity_type_id' => $installer->getEntityTypeId('catalog_product'),
41+
'is_global' => 1,
42+
'is_user_defined' => 1,
43+
'frontend_input' => 'select',
44+
'is_unique' => 0,
45+
'is_required' => 0,
46+
'is_searchable' => 1,
47+
'is_visible_in_advanced_search' => 1,
48+
'is_comparable' => 1,
49+
'is_filterable' => 1,
50+
'is_filterable_in_search' => 1,
51+
'is_used_for_promo_rules' => 0,
52+
'is_html_allowed_on_front' => 1,
53+
'is_visible_on_front' => 1,
54+
'used_in_product_listing' => 1,
55+
'used_for_sort_by' => 1,
56+
'frontend_label' => ['Test Configurable'],
57+
'backend_type' => 'int',
58+
'option' => [
59+
'value' => ['option_0' => ['Option 1'], 'option_1' => ['Option 2']],
60+
'order' => ['option_0' => 1, 'option_1' => 2],
61+
],
62+
'default_value' => 'option_0'
63+
]
64+
);
65+
6466
$attributeRepository->save($attribute);
6567

6668
/* Assign attribute to attribute set */
6769
$installer->addAttributeToGroup('catalog_product', 'Default', 'General', $attribute->getId());
6870
}
69-
7071
// create a second attribute
71-
/** @var Attribute $secondAttribute */
72-
$secondAttribute = $eavConfig->getAttribute('catalog_product', ' second_test_configurable');
73-
if (!$secondAttribute->getId()) {
74-
$secondAttribute->setData([
75-
'attribute_code' => 'second_test_configurable',
76-
'entity_type_id' => $installer->getEntityTypeId('catalog_product'),
77-
'is_global' => 1,
78-
'is_user_defined' => 1,
79-
'frontend_input' => 'select',
80-
'is_unique' => 0,
81-
'is_required' => 0,
82-
'is_searchable' => 0,
83-
'is_visible_in_advanced_search' => 0,
84-
'is_comparable' => 1,
85-
'is_filterable' => 1,
86-
'is_filterable_in_search' => 1,
87-
'is_used_for_promo_rules' => 0,
88-
'is_html_allowed_on_front' => 1,
89-
'is_visible_on_front' => 1,
90-
'used_in_product_listing' => 1,
91-
'used_for_sort_by' => 1,
92-
'frontend_label' => ['Second Test Configurable'],
93-
'backend_type' => 'int',
94-
'option' => [
95-
'value' => ['option_0' => ['Option 3'], 'option_1' => ['Option 4']],
96-
'order' => ['option_0' => 1, 'option_1' => 2],
97-
],
98-
'default' => ['option_0']
99-
]);
100-
$attributeRepository->save($secondAttribute);
72+
if (!$attribute1->getId()) {
73+
74+
/** @var $attribute1 \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
75+
$attribute1 = Bootstrap::getObjectManager()->create(
76+
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
77+
);
78+
79+
/** @var AttributeRepositoryInterface $attributeRepository */
80+
$attributeRepository = Bootstrap::getObjectManager()->create(AttributeRepositoryInterface::class);
81+
82+
$attribute1->setData(
83+
[
84+
'attribute_code' => 'second_test_configurable',
85+
'entity_type_id' => $installer->getEntityTypeId('catalog_product'),
86+
'is_global' => 1,
87+
'is_user_defined' => 1,
88+
'frontend_input' => 'select',
89+
'is_unique' => 0,
90+
'is_required' => 0,
91+
'is_searchable' => 1,
92+
'is_visible_in_advanced_search' => 1,
93+
'is_comparable' => 1,
94+
'is_filterable' => 1,
95+
'is_filterable_in_search' => 1,
96+
'is_used_for_promo_rules' => 0,
97+
'is_html_allowed_on_front' => 1,
98+
'is_visible_on_front' => 1,
99+
'used_in_product_listing' => 1,
100+
'used_for_sort_by' => 1,
101+
'frontend_label' => ['Second Test Configurable'],
102+
'backend_type' => 'int',
103+
'option' => [
104+
'value' => ['option_0' => ['Option 3'], 'option_1' => ['Option 4']],
105+
'order' => ['option_0' => 1, 'option_1' => 2],
106+
],
107+
'default' => ['option_0']
108+
]
109+
);
110+
111+
$attributeRepository->save($attribute1);
101112

102113
/* Assign attribute to attribute set */
103114
$installer->addAttributeToGroup(
104115
'catalog_product',
105116
$attributeSet->getId(),
106117
$attributeSet->getDefaultGroupId(),
107-
$secondAttribute->getId()
118+
$attribute1->getId()
108119
);
109120
}
110121

111122
$eavConfig->clear();
112123

113-
/** @var ProductRepositoryInterface $productRepository */
114-
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
124+
/** @var \Magento\Framework\ObjectManagerInterface $objectManager */
125+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
126+
127+
/** @var $productRepository \Magento\Catalog\Api\ProductRepositoryInterface */
128+
$productRepository = $objectManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
115129
$productsWithNewAttributeSet = ['simple', '12345', 'simple-4'];
116130

117131
foreach ($productsWithNewAttributeSet as $sku) {
@@ -125,14 +139,14 @@
125139
'is_in_stock' => 1]
126140
);
127141
$productRepository->save($product);
128-
} catch (NoSuchEntityException $e) {
142+
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
129143

130144
}
131145
}
146+
CacheCleaner::cleanAll();
132147

133-
/** @var IndexerCollection $indexerCollection */
134-
$indexerCollection = $objectManager->get(IndexerCollection::class)->load();
135-
/** @var Indexer $indexer */
136-
foreach ($indexerCollection->getItems() as $indexer) {
137-
$indexer->reindexAll();
138-
}
148+
// Run from CLI due to some classes involved in reindex process have state which do not allow to reindex
149+
$appDir = dirname(Bootstrap::getInstance()->getAppTempDir());
150+
$out = '';
151+
// phpcs:ignore Magento2.Security.InsecureFunction
152+
exec("php -f {$appDir}/bin/magento indexer:reindex catalogsearch_fulltext", $out);

dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_layered_navigation_custom_attribute_rollback.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,43 @@
55
*/
66
declare(strict_types=1);
77

8-
use Magento\Eav\Api\Data\AttributeInterface;
9-
use Magento\Eav\Model\Config;
10-
use Magento\Eav\Model\Entity\Attribute\Set as AttributeSet;
11-
use Magento\Eav\Model\Entity\Type;
12-
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection as AttributeSetCollection;
13-
use Magento\Framework\App\ObjectManager;
148
use Magento\TestFramework\Helper\Bootstrap;
159
use Magento\Eav\Api\AttributeRepositoryInterface;
10+
use Magento\TestFramework\Helper\CacheCleaner;
1611
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
1712

1813
Resolver::getInstance()->requireDataFixture('Magento/Eav/_files/empty_attribute_set_rollback.php');
1914
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/categories_rollback.php');
20-
/** @var ObjectManager $objectManager */
21-
$objectManager = Bootstrap::getObjectManager();
2215

23-
$eavConfig = $objectManager->get(Config::class);
16+
$eavConfig = Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class);
2417
$attributesToDelete = ['test_configurable', 'second_test_configurable'];
2518
/** @var AttributeRepositoryInterface $attributeRepository */
26-
$attributeRepository = $objectManager->get(AttributeRepositoryInterface::class);
19+
$attributeRepository = Bootstrap::getObjectManager()->get(AttributeRepositoryInterface::class);
2720

2821
foreach ($attributesToDelete as $attributeCode) {
29-
/** @var AttributeInterface $attribute */
22+
/** @var \Magento\Eav\Api\Data\AttributeInterface $attribute */
3023
$attribute = $attributeRepository->get('catalog_product', $attributeCode);
3124
$attributeRepository->delete($attribute);
3225
}
26+
/** @var $product \Magento\Catalog\Model\Product */
27+
$objectManager = Bootstrap::getObjectManager();
28+
29+
$entityType = $objectManager->create(\Magento\Eav\Model\Entity\Type::class)->loadByCode('catalog_product');
3330

3431
// remove attribute set
35-
$entityType = $objectManager->create(Type::class)->loadByCode('catalog_product');
36-
/** @var AttributeSetCollection $attributeSetCollection */
32+
33+
/** @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection $attributeSetCollection */
3734
$attributeSetCollection = $objectManager->create(
38-
AttributeSetCollection::class
35+
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection::class
3936
);
4037
$attributeSetCollection->addFilter('attribute_set_name', 'second_attribute_set');
4138
$attributeSetCollection->addFilter('entity_type_id', $entityType->getId());
42-
$attributeSetCollection->setOrder('attribute_set_id');
39+
$attributeSetCollection->setOrder('attribute_set_id'); // descending is default value
4340
$attributeSetCollection->setPageSize(1);
4441
$attributeSetCollection->load();
4542

46-
/** @var AttributeSet $attributeSet */
43+
/** @var \Magento\Eav\Model\Entity\Attribute\Set $attributeSet */
4744
$attributeSet = $attributeSetCollection->fetchItem();
4845
$attributeSet->delete();
46+
47+
CacheCleaner::cleanAll();

0 commit comments

Comments
 (0)