Skip to content

Commit 2226341

Browse files
committed
MAGETWO-87144: Create tests for all product types
- added and fixed Bundle product validations
1 parent ab6f8cb commit 2226341

File tree

2 files changed

+41
-32
lines changed

2 files changed

+41
-32
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/BundleProductViewTest.php

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,50 +28,48 @@ public function testAllFielsBundleProducts()
2828
products(filter: {sku: {eq: "{$productSku}"}})
2929
{
3030
items{
31-
id
32-
attribute_set_id
33-
created_at
34-
name
3531
sku
3632
type_id
37-
updated_at
33+
id
34+
name
35+
attribute_set_id
3836
... on PhysicalProductInterface {
3937
weight
4038
}
41-
category_ids
39+
category_ids
4240
... on BundleProduct {
4341
dynamic_sku
4442
dynamic_price
4543
dynamic_weight
4644
price_view
4745
ship_bundle_items
48-
items {
49-
option_id
50-
title
51-
required
52-
type
53-
position
54-
sku
55-
options {
56-
id
57-
product_id
58-
qty
59-
position
60-
is_default
61-
price
62-
price_type
63-
can_change_quantity
64-
product {
65-
id
66-
name
67-
sku
68-
}
69-
}
70-
}
46+
items {
47+
option_id
48+
title
49+
required
50+
type
51+
position
52+
sku
53+
options {
54+
id
55+
qty
56+
position
57+
is_default
58+
price
59+
price_type
60+
can_change_quantity
61+
label
62+
product {
63+
id
64+
name
65+
sku
66+
type_id
67+
}
68+
}
69+
}
7170
}
7271
}
73-
}
74-
72+
}
7573
}
7674
QUERY;
7775

@@ -109,6 +107,9 @@ private function assertBundleBaseFields($product, $actualResponse)
109107
['response_field' => 'sku', 'expected_value' => $product->getSku()],
110108
['response_field' => 'type_id', 'expected_value' => $product->getTypeId()],
111109
['response_field' => 'id', 'expected_value' => $product->getId()],
110+
['response_field' => 'name', 'expected_value' => $product->getName()],
111+
['response_field' => 'attribute_set_id', 'expected_value' => $product->getAttributeSetId()],
112+
['response_field' => 'weight', 'expected_value' => $product->getWeight()],
112113
['response_field' => 'dynamic_price', 'expected_value' => !(bool)$product->getPriceType()],
113114
['response_field' => 'dynamic_weight', 'expected_value' => !(bool)$product->getWeightType()],
114115
['response_field' => 'dynamic_sku', 'expected_value' => !(bool)$product->getSkuType()]
@@ -133,6 +134,9 @@ private function assertBundleProductOptions($product, $actualResponse)
133134
$option = $options[0];
134135
$bundleProductLinks = $option->getProductLinks();
135136
$bundleProductLink = $bundleProductLinks[0];
137+
$childProductSku = $bundleProductLink->getSku();
138+
$productRepository = ObjectManager::getInstance()->get(ProductRepositoryInterface::class);
139+
$childProduct = $productRepository->get($childProductSku);
136140
$this->assertEquals(1, count($options));
137141
$this->assertResponseFields(
138142
$actualResponse['items'][0],
@@ -154,12 +158,16 @@ private function assertBundleProductOptions($product, $actualResponse)
154158
'is_default' => (bool)$bundleProductLink->getIsDefault(),
155159
'price' => $bundleProductLink->getPrice(),
156160
'price_type' => self::KEY_PRICE_TYPE_FIXED,
157-
'can_change_quantity' => $bundleProductLink->getCanChangeQuantity()
161+
'can_change_quantity' => $bundleProductLink->getCanChangeQuantity(),
162+
'label' => $childProduct->getName()
158163
]
159164
);
160165
$this->assertResponseFields(
161166
$actualResponse['items'][0]['options'][0]['product'],
162167
[
168+
'id' => $childProduct->getId(),
169+
'name' => $childProduct->getName(),
170+
'type_id' => $childProduct->getTypeId(),
163171
'sku' => $bundleProductLink->getSku()
164172
]
165173
);

dev/tests/integration/testsuite/Magento/Bundle/_files/product.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
$product->setTypeId('bundle')
2323
->setId(3)
2424
->setAttributeSetId(4)
25+
->setWeight(2)
2526
->setWebsiteIds([1])
2627
->setName('Bundle Product')
2728
->setSku('bundle-product')

0 commit comments

Comments
 (0)