Skip to content

Commit 5743eb4

Browse files
committed
ACP2E-3399: GraphQL Response for Order placement does not include the exception message
1 parent b2c859c commit 5743eb4

File tree

1 file changed

+19
-41
lines changed
  • dev/tests/integration/testsuite/Magento/Rule/Model/Condition/Sql

1 file changed

+19
-41
lines changed

dev/tests/integration/testsuite/Magento/Rule/Model/Condition/Sql/BuilderTest.php

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation;
1111
use Magento\Catalog\Setup\CategorySetup;
1212
use Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend;
13-
use Magento\Eav\Test\Fixture\AttributeOption as AttributeOptionFixture;
1413
use Magento\Framework\DB\Select;
1514
use Magento\Framework\Exception\LocalizedException;
15+
use Magento\TestFramework\Fixture\DataFixtureStorage;
16+
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
1617
use Magento\TestFramework\Helper\Bootstrap;
1718
use Magento\TestFramework\Fixture\DataFixture;
1819
use Magento\Catalog\Test\Fixture\MultiselectAttribute;
@@ -21,6 +22,7 @@
2122
use Magento\CatalogWidget\Model\Rule\Condition\Combine as CombineCondition;
2223
use Magento\CatalogWidget\Model\Rule\Condition\Product as ProductCondition;
2324
use Magento\Catalog\Model\ResourceModel\Product\Collection;
25+
use Magento\TestFramework\Helper\Bootstrap as BootstrapHelper;
2426
use PHPUnit\Framework\TestCase;
2527

2628
/**
@@ -33,20 +35,26 @@ class BuilderTest extends TestCase
3335
*/
3436
private Builder $model;
3537

38+
/**
39+
* @var DataFixtureStorage
40+
*/
41+
private DataFixtureStorage $fixtures;
42+
3643
/**
3744
* @inheritDoc
3845
*/
3946
protected function setUp(): void
4047
{
4148
$this->model = Bootstrap::getObjectManager()->create(Builder::class);
49+
$this->fixtures = BootstrapHelper::getObjectManager()->get(DataFixtureStorageManager::class)->getStorage();
4250
}
4351

4452
/**
4553
* @param array $conditions
4654
* @param string $expectedWhere
4755
* @param string $expectedOrder
4856
* @return void
49-
* @throws LocalizedException
57+
* @throws LocalizedException|\PHPUnit\Framework\MockObject\Exception
5058
* @dataProvider attachConditionToCollectionDataProvider
5159
*/
5260
#[
@@ -61,27 +69,9 @@ protected function setUp(): void
6169
'frontend_input' => 'multiselect',
6270
'backend_type' => 'text',
6371
'attribute_model' => Attribute::class,
72+
'options' => ['red', 'white']
6473
],
6574
'multiselect'
66-
),
67-
DataFixture(
68-
AttributeOptionFixture::class,
69-
[
70-
'attribute_code' => 'multiselect.attribute_code$',
71-
'label' => 'red',
72-
'sort_order' => 20
73-
],
74-
'multiselect_custom_attribute_option_1'
75-
),
76-
DataFixture(
77-
AttributeOptionFixture::class,
78-
[
79-
'attribute_code' => 'multiselect.attribute_code$',
80-
'sort_order' => 10,
81-
'label' => 'white',
82-
'is_default' => true
83-
],
84-
'multiselect_custom_attribute_option_2'
8575
)
8676
]
8777
public function testAttachConditionToCollection(
@@ -94,23 +84,11 @@ public function testAttachConditionToCollection(
9484
$collection = $collectionFactory->create();
9585
foreach ($conditions as $key => $condition) {
9686
if (isset($condition['attribute']) && $condition['attribute'] === 'multi_select_attr') {
97-
$multiselect = Bootstrap::getObjectManager()->create(
98-
Attribute::class
99-
);
100-
$multiselect->load('multi_select_attr', 'attribute_code');
101-
$multiselectAttributeOptionIds = [];
102-
$optionIndex = 1;
103-
foreach ($multiselect->getOptions() as $option) {
104-
if ($option->getValue()) {
105-
$multiselectAttributeOptionIds[] = $option->getValue();
106-
$expectedWhere = str_replace(
107-
"#optionAtrId$optionIndex#",
108-
$option->getValue(),
109-
$expectedWhere
110-
);
111-
$optionIndex++;
112-
}
113-
}
87+
$multiselectAttributeOptionIds = [
88+
$this->fixtures->get('multiselect')->getData('red'),
89+
$this->fixtures->get('multiselect')->getData('white')
90+
];
91+
$expectedWhere = str_replace(["red", "white"], $multiselectAttributeOptionIds, $expectedWhere);
11492

11593
$conditions[$key]['value'] = $multiselectAttributeOptionIds;
11694
}
@@ -215,9 +193,9 @@ public static function attachConditionToCollectionDataProvider(): array
215193
"(((`e`.`entity_id` IN (SELECT `catalog_category_product`.`product_id` FROM " .
216194
"`catalog_category_product` WHERE (category_id IN ('3')))) " .
217195
"AND(`e`.`sku` IN ('sku1', 'sku2', 'sku3')) AND(`at_multi_select_attr`.`value` IN " .
218-
"('#optionAtrId1#', '#optionAtrId2#') OR " .
219-
"(FIND_IN_SET ('#optionAtrId1#', `at_multi_select_attr`.`value`) > 0) OR " .
220-
"(FIND_IN_SET ('#optionAtrId2#', `at_multi_select_attr`.`value`) > 0))",
196+
"('red', 'white') OR " .
197+
"(FIND_IN_SET ('red', `at_multi_select_attr`.`value`) > 0) OR " .
198+
"(FIND_IN_SET ('white', `at_multi_select_attr`.`value`) > 0))",
221199
"ORDER BY (FIELD(`e`.`sku`, 'sku1', 'sku2', 'sku3'))"
222200
]
223201
];

0 commit comments

Comments
 (0)