Skip to content

Commit 2be10b7

Browse files
author
Jakub Winkler
committed
#bug-33486 - fixing integration tests for multiselect attributes stores in _text entity table
1 parent 16ef8b1 commit 2be10b7

File tree

10 files changed

+56
-23
lines changed

10 files changed

+56
-23
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Model/ProductGettersTest.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,36 @@ public function testGetAttributeTextArray()
215215
$product = $this->productRepository->get('simple_ms_2');
216216
$product->getAttributeText('multiselect_attribute');
217217
$expected = [
218-
'Option 2',
219-
'Option 3',
220-
'Option 4 "!@#$%^&*'
218+
'Multiselect option 2',
219+
'Multiselect option 3',
220+
'Multiselect option 4'
221221
];
222222
self::assertEquals(
223223
$expected,
224224
$product->getAttributeText('multiselect_attribute')
225225
);
226226
}
227227

228+
/**
229+
* @magentoDataFixture Magento/Catalog/_files/products_with_multiselect_attribute.php
230+
*/
231+
public function testMultipleMultiselectValues()
232+
{
233+
$expectedArray = [];
234+
235+
for ($i = 1; $i < 200; $i++) {
236+
$expectedArray[] = sprintf('Multiselect option %d', $i);
237+
}
238+
239+
$product = $this->productRepository->get('simple_ms_3');
240+
241+
self::assertEquals(
242+
$expectedArray,
243+
$product->getAttributeText('multiselect_attribute')
244+
);
245+
}
246+
247+
228248
public function testGetCustomDesignDate()
229249
{
230250
$this->assertEquals(['from' => null, 'to' => null], $this->_model->getCustomDesignDate());

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
$attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
1313
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
1414
);
15+
16+
$valueOptionArray = [];
17+
$orderArray = [];
18+
19+
for ($i = 1; $i < 200; $i++) {
20+
$valueOptionArray[sprintf('option_%d', $i)] = [sprintf('Multiselect option %d', $i)];
21+
$orderArray[sprintf('option_%d', $i)] = $i;
22+
}
23+
1524
$entityType = $installer->getEntityTypeId('catalog_product');
1625
if (!$attribute->loadByCode($entityType, 'multiselect_attribute')->getAttributeId()) {
1726
$attribute->setData(
@@ -34,21 +43,11 @@
3443
'used_in_product_listing' => 0,
3544
'used_for_sort_by' => 0,
3645
'frontend_label' => ['Multiselect Attribute'],
37-
'backend_type' => 'varchar',
46+
'backend_type' => 'text',
3847
'backend_model' => \Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend::class,
3948
'option' => [
40-
'value' => [
41-
'option_1' => ['Option 1'],
42-
'option_2' => ['Option 2'],
43-
'option_3' => ['Option 3'],
44-
'option_4' => ['Option 4 "!@#$%^&*']
45-
],
46-
'order' => [
47-
'option_1' => 1,
48-
'option_2' => 2,
49-
'option_3' => 3,
50-
'option_4' => 4,
51-
],
49+
'value' => $valueOptionArray,
50+
'order' => $orderArray
5251
],
5352
]
5453
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
'used_in_product_listing' => 0,
4242
'used_for_sort_by' => 0,
4343
'frontend_label' => ['Multiselect Attribute'],
44-
'backend_type' => 'varchar',
44+
'backend_type' => 'text',
4545
'backend_model' => ArrayBackend::class,
4646
'option' => [
4747
'value' => [

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
'used_in_product_listing' => 0,
3434
'used_for_sort_by' => 0,
3535
'frontend_label' => ['Multiselect Attribute'],
36-
'backend_type' => 'varchar',
36+
'backend_type' => 'text',
3737
'backend_model' => \Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend::class,
3838
'option' => [
3939
'value' => [

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
'used_in_product_listing' => 0,
3535
'used_for_sort_by' => 0,
3636
'frontend_label' => ['Multiselect Attribute with Source Model'],
37-
'backend_type' => 'varchar',
37+
'backend_type' => 'text',
3838
'backend_model' => \Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend::class,
3939
'source_model' => \Magento\Catalog\_files\MultiselectSourceMock::class
4040
]

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,17 @@
5454
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
5555
->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1])
5656
->save();
57+
58+
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class);
59+
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
60+
->setId($optionIds[2] * 10)
61+
->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default'))
62+
->setWebsiteIds([1])
63+
->setName('With Multiselect 3')
64+
->setSku('simple_ms_3')
65+
->setPrice(10)
66+
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
67+
->setMultiselectAttribute(array_values($optionIds))
68+
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
69+
->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1])
70+
->save();

dev/tests/integration/testsuite/Magento/Elasticsearch/Model/Adapter/ElasticsearchTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function createNewAttribute(): void
140140
'used_in_product_listing' => 0,
141141
'used_for_sort_by' => 0,
142142
'frontend_label' => ['Multiselect Attribute'],
143-
'backend_type' => 'varchar',
143+
'backend_type' => 'text',
144144
'backend_model' => ArrayBackend::class,
145145
'option' => [
146146
'value' => [

dev/tests/integration/testsuite/Magento/Elasticsearch/_files/multiselect_attribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
'used_in_product_listing' => 0,
3535
'used_for_sort_by' => 0,
3636
'frontend_label' => ['Multiselect Attribute'],
37-
'backend_type' => 'varchar',
37+
'backend_type' => 'text',
3838
'backend_model' => \Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend::class,
3939
'option' => [
4040
'value' => [

dev/tests/integration/testsuite/Magento/Framework/Search/_files/filterable_attribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
'value' => ['option_0' => ['Option 1'], 'option_1' => ['Option 2']],
5555
'order' => ['option_0' => 1, 'option_1' => 2],
5656
],
57-
'backend_type' => 'varchar',
57+
'backend_type' => 'text',
5858
]
5959
);
6060
$multiselectAttribute->save();

dev/tests/integration/testsuite/Magento/Sales/_files/order_address_with_multi_attribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
'frontend_input' => 'multiselect',
4141
'frontend_label' => ['Multiselect Attribute'],
4242
'sort_order' => '0',
43-
'backend_type' => 'varchar',
43+
'backend_type' => 'text',
4444
'is_user_defined' => 1,
4545
'is_system' => 0,
4646
'is_required' => '0',

0 commit comments

Comments
 (0)