Skip to content

Commit fa9ce55

Browse files
committed
ACQE-8253: [AC-11810] [Issue] Magento2.4.6-p4 Order API Simple Item missing price
- Fixed static checks fail
1 parent ee106e1 commit fa9ce55

File tree

1 file changed

+53
-39
lines changed

1 file changed

+53
-39
lines changed

dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderApiConfigurableVariationsPriceTest.php

Lines changed: 53 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
27
declare(strict_types=1);
38

49
namespace Magento\Sales\Service\V1;
@@ -27,6 +32,11 @@ class OrderApiConfigurableVariationsPriceTest extends WebapiAbstract
2732
{
2833
private const RESOURCE_PATH = '/V1/orders';
2934

35+
/**
36+
* Fixture storage manager for resolving test data.
37+
*
38+
* @var DataFixtureStorage
39+
*/
3040
private DataFixtureStorage $fixtures;
3141

3242
/**
@@ -40,18 +50,23 @@ protected function setUp(): void
4050
}
4151

4252
#[
43-
DataFixture(AttributeFixture::class, [
44-
'frontend_input' => 'select',
45-
'options' => ['40', '42'],
46-
'is_configurable' => true,
47-
'is_global' => true
48-
], as: 'attribute'),
49-
DataFixture(ProductFixture::class,
53+
DataFixture(
54+
AttributeFixture::class,
55+
[
56+
'frontend_input' => 'select',
57+
'options' => ['40', '42'],
58+
'is_configurable' => true,
59+
'is_global' => true,
60+
],
61+
as: 'attribute'
62+
),
63+
DataFixture(
64+
ProductFixture::class,
5065
[
5166
'price' => 100,
5267
'custom_attributes' => [
53-
['attribute_code' => '$attribute.attribute_code$', 'value' => '40']
54-
]
68+
['attribute_code' => '$attribute.attribute_code$', 'value' => '40'],
69+
],
5570
],
5671
as: 'product1'
5772
),
@@ -60,31 +75,34 @@ protected function setUp(): void
6075
[
6176
'price' => 100,
6277
'custom_attributes' => [
63-
['attribute_code' => '$attribute.attribute_code$', 'value' => '42']
64-
]
78+
['attribute_code' => '$attribute.attribute_code$', 'value' => '42'],
79+
],
6580
],
6681
as: 'product2'
6782
),
6883
DataFixture(
6984
ConfigurableProductFixture::class,
7085
[
71-
'_options' => ['$attribute$'],
72-
'_links' => ['$product1$', '$product2$'],
73-
'custom_attributes' => [
74-
['attribute_code' => '$attribute.attribute_code$', 'value' => '40']
75-
]
86+
'_options' => ['$attribute$'],
87+
'_links' => ['$product1$', '$product2$'],
88+
'custom_attributes' => [
89+
['attribute_code' => '$attribute.attribute_code$', 'value' => '40'],
90+
],
7691
],
7792
'configurable_product'
7893
),
7994
DataFixture(GuestCart::class, as: 'cart'),
8095
DataFixture(Customer::class, as: 'customer'),
8196
DataFixture(CustomerCart::class, ['customer_id' => '$customer.id$'], as: 'quote'),
82-
DataFixture(AddProductToCart::class, [
83-
'cart_id' => '$cart.id$',
84-
'product_id' => '$configurable_product.id$',
85-
'child_product_id' => '$product1.id$',
86-
'qty' => 1
87-
]),
97+
DataFixture(
98+
AddProductToCart::class,
99+
[
100+
'cart_id' => '$cart.id$',
101+
'product_id' => '$configurable_product.id$',
102+
'child_product_id' => '$product1.id$',
103+
'qty' => 1,
104+
]
105+
),
88106
DataFixture(SetBillingAddress::class, ['cart_id' => '$cart.id$']),
89107
DataFixture(SetShippingAddress::class, ['cart_id' => '$cart.id$']),
90108
DataFixture(SetGuestEmail::class, ['cart_id' => '$cart.id$']),
@@ -95,12 +113,12 @@ protected function setUp(): void
95113
/**
96114
* Validates that simple products linked to a configurable parent in an order:
97115
* - Exist in the response
98-
* - Are linked correctly via parent_item_id
99-
* - Carry expected pricing logic (either 0.0 or actual price depending on Magento behavior)
116+
* - Are linked via parent_item_id
117+
* - Carry expected pricing logic
100118
*/
101119
public function testSimpleItemsAssignedToConfigurableHaveValidPrice(): void
102120
{
103-
$orderData = $this->callOrderApi((string)$this->fixtures->get('order')->getEntityId());
121+
$orderData = $this->callOrderApi((string) $this->fixtures->get('order')->getEntityId());
104122

105123
$this->assertArrayHasKey('items', $orderData);
106124
$this->assertIsArray($orderData['items']);
@@ -129,27 +147,26 @@ public function testSimpleItemsAssignedToConfigurableHaveValidPrice(): void
129147

130148
foreach ($simpleItemsWithParent as $item) {
131149
$this->assertNotEmpty($item['sku'], 'Simple item must have SKU.');
150+
$price = (float) $item['price'];
132151

133-
$price = (float)$item['price'];
134-
$this->assertTrue(true, sprintf(
135-
'Simple item "%s" has price %s (valid if parent holds pricing).',
136-
$item['sku'],
137-
$price
138-
));
152+
$this->assertTrue(
153+
true,
154+
sprintf('Simple item "%s" has price %s.', $item['sku'], $price)
155+
);
139156

140157
if ($price > 0.0) {
141158
$this->assertGreaterThan(
142159
0.0,
143160
$price,
144-
sprintf('Simple item "%s" should have valid price if used independently.', $item['sku'])
161+
sprintf('Simple item "%s" should have price > 0.', $item['sku'])
145162
);
146163
}
147164
}
148165

149166
foreach ($unlinkedSimples as $item) {
150167
$this->assertEquals(
151168
0.0,
152-
(float)$item['price'],
169+
(float) $item['price'],
153170
'Unlinked simple item should have zero price.'
154171
);
155172
}
@@ -158,7 +175,7 @@ public function testSimpleItemsAssignedToConfigurableHaveValidPrice(): void
158175
}
159176

160177
/**
161-
* Calls the REST API to retrieve order data by order ID.
178+
* Calls the REST and SOAP APIs to retrieve order data by order ID.
162179
*
163180
* @param string $orderId
164181
* @return array
@@ -181,7 +198,7 @@ private function callOrderApi(string $orderId): array
181198
}
182199

183200
/**
184-
* Validates that each simple product has a valid parent link to a configurable item.
201+
* Validates that simple items link correctly to one of the configurable parent items.
185202
*
186203
* @param array $configurableItems
187204
* @param array $simpleItems
@@ -195,10 +212,7 @@ private function assertSimpleItemsHaveValidParent(array $configurableItems, arra
195212
$this->assertContains(
196213
$item['parent_item_id'],
197214
$configurableItemIds,
198-
sprintf(
199-
'Simple item "%s" must link to a configurable parent.',
200-
$item['item_id'] ?? 'N/A'
201-
)
215+
sprintf('Simple item "%s" must link to a configurable parent.', $item['item_id'] ?? 'N/A')
202216
);
203217
}
204218
}

0 commit comments

Comments
 (0)