Skip to content

Commit a677056

Browse files
ACQE-8898: Create configurable product with child by REST API
- Used constant variable instead of direct values.
1 parent 94e8ed9 commit a677056

File tree

1 file changed

+11
-31
lines changed

1 file changed

+11
-31
lines changed

dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/ConfigurableProductWorkflowTest.php

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
use Magento\TestFramework\Fixture\DataFixtureStorage;
2020
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
2121
use Magento\User\Test\Fixture\User;
22-
22+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
23+
use Magento\Catalog\Model\Product\Visibility;
24+
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
2325
/**
2426
* Complete workflow test for configurable product creation via REST API
2527
*/
@@ -87,35 +89,13 @@ protected function setUp(): void
8789
DataFixture(
8890
AttributeFixture::class,
8991
[
90-
'entity_type_id' => 4,
9192
'attribute_code' => 'test_configurable',
9293
'frontend_input' => 'select',
9394
'frontend_label' => 'Test Configurable',
94-
'is_required' => false,
95-
'is_user_defined' => true,
96-
'is_unique' => false,
97-
'is_global' => 1,
98-
'is_visible' => true,
99-
'is_searchable' => false,
100-
'is_comparable' => false,
101-
'is_visible_on_front' => false,
102-
'is_html_allowed_on_front' => false,
103-
'is_used_for_price_rules' => false,
104-
'is_filterable' => false,
105-
'is_filterable_in_search' => false,
106-
'used_in_product_listing' => false,
107-
'used_for_sort_by' => false,
108-
'is_visible_in_advanced_search' => false,
109-
'is_wysiwyg_enabled' => false,
110-
'is_used_for_promo_rules' => false,
111-
'is_required_in_admin_store' => false,
112-
'is_used_in_grid' => false,
113-
'is_visible_in_grid' => false,
114-
'is_filterable_in_grid' => false,
11595
'is_configurable' => true,
11696
'options' => [
117-
['label' => 'Option 1', 'sort_order' => 10, 'is_default' => false],
118-
['label' => 'Option 2', 'sort_order' => 20, 'is_default' => false],
97+
['label' => 'Option 1', 'sort_order' => 10],
98+
['label' => 'Option 2', 'sort_order' => 20],
11999
],
120100
],
121101
'configurable_attribute'
@@ -140,9 +120,9 @@ public function testCompleteConfigurableProductWorkflow(): void
140120
// Create configurable product
141121
$configurableProductData = $this->createConfigurableProduct();
142122
$this->assertEquals(self::CONFIGURABLE_PRODUCT_SKU, $configurableProductData['sku']);
143-
$this->assertEquals('configurable', $configurableProductData['type_id']);
144-
$this->assertEquals(1, $configurableProductData['status']); // Enabled
145-
$this->assertEquals(4, $configurableProductData['visibility']); // Catalog, Search
123+
$this->assertEquals('configurable', Configurable::TYPE_CODE);
124+
$this->assertEquals(1, Status::STATUS_ENABLED);
125+
$this->assertEquals(4,Visibility::VISIBILITY_BOTH);
146126

147127
// Add color attribute options to configurable product
148128
$optionResult = $this->addConfigurableProductOption(
@@ -256,10 +236,10 @@ private function createConfigurableProduct(): array
256236
'sku' => self::CONFIGURABLE_PRODUCT_SKU,
257237
'name' => 'Configurable Product Created by API',
258238
'attribute_set_id' => 4, // Default attribute set
259-
'type_id' => 'configurable',
239+
'type_id' => Configurable::TYPE_CODE,
260240
'price' => 99.00,
261-
'status' => 1, // Enabled
262-
'visibility' => 4, // Catalog, Search
241+
'status' => Status::STATUS_ENABLED,
242+
'visibility' => Visibility::VISIBILITY_BOTH,
263243
'weight' => 1.0,
264244
'custom_attributes' => [
265245
[

0 commit comments

Comments
 (0)