Skip to content

Commit afaa455

Browse files
author
Gurzhyi, Andrii
committed
MAGETWO-48227: Fix API/Integration tests
- Fixed tests
1 parent 785e560 commit afaa455

File tree

2 files changed

+170
-1
lines changed

2 files changed

+170
-1
lines changed

dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
[
7171
'attribute_id' => $attribute->getId(),
7272
'code' => $attribute->getAttributeCode(),
73-
'label' => 'test',
73+
'label' => $attribute->getStoreLabel(),
7474
'position' => '0',
7575
'values' => $attributeValues,
7676
],
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
use Magento\Catalog\Api\CategoryLinkManagementInterface;
8+
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
9+
use Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory;
10+
use Magento\Catalog\Api\ProductRepositoryInterface;
11+
use Magento\Catalog\Model\Product;
12+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
13+
use Magento\Catalog\Model\Product\Type;
14+
use Magento\Catalog\Model\Product\Visibility;
15+
use Magento\TestFramework\Helper\Bootstrap;
16+
use Magento\TestFramework\ObjectManager;
17+
18+
Bootstrap::getInstance()->reinitialize();
19+
20+
/** @var ObjectManager $objectManager */
21+
$objectManager = Bootstrap::getObjectManager();
22+
23+
/** @var CategoryLinkManagementInterface $categoryLinkManagement */
24+
$categoryLinkManagement = $objectManager->create(CategoryLinkManagementInterface::class);
25+
26+
/** @var $product Product */
27+
$product = $objectManager->create(Product::class);
28+
$product->isObjectNew(true);
29+
$product->setTypeId(Type::TYPE_SIMPLE)
30+
->setId(77)
31+
->setAttributeSetId(4)
32+
->setWebsiteIds([1])
33+
->setName('Simple Product')
34+
->setSku('simple_77')
35+
->setPrice(10)
36+
->setWeight(1)
37+
->setShortDescription("Short description")
38+
->setTaxClassId(0)
39+
->setTierPrice(
40+
[
41+
[
42+
'website_id' => 0,
43+
'cust_group' => \Magento\Customer\Model\Group::CUST_GROUP_ALL,
44+
'price_qty' => 2,
45+
'price' => 8,
46+
],
47+
[
48+
'website_id' => 0,
49+
'cust_group' => \Magento\Customer\Model\Group::CUST_GROUP_ALL,
50+
'price_qty' => 5,
51+
'price' => 5,
52+
],
53+
[
54+
'website_id' => 0,
55+
'cust_group' => \Magento\Customer\Model\Group::NOT_LOGGED_IN_ID,
56+
'price_qty' => 3,
57+
'price' => 5,
58+
],
59+
]
60+
)
61+
->setDescription('Description with <b>html tag</b>')
62+
->setMetaTitle('meta title')
63+
->setMetaKeyword('meta keyword')
64+
->setMetaDescription('meta description')
65+
->setVisibility(Visibility::VISIBILITY_BOTH)
66+
->setStatus(Status::STATUS_ENABLED)
67+
->setStockData(
68+
[
69+
'use_config_manage_stock' => 1,
70+
'qty' => 100,
71+
'is_qty_decimal' => 0,
72+
'is_in_stock' => 1,
73+
]
74+
)->setCanSaveCustomOptions(true)
75+
->setHasOptions(true);
76+
77+
$oldOptions = [
78+
[
79+
'previous_group' => 'text',
80+
'title' => 'Test Field',
81+
'type' => 'field',
82+
'is_require' => 1,
83+
'sort_order' => 0,
84+
'price' => 1,
85+
'price_type' => 'fixed',
86+
'sku' => '1-text',
87+
'max_characters' => 100,
88+
],
89+
[
90+
'previous_group' => 'date',
91+
'title' => 'Test Date and Time',
92+
'type' => 'date_time',
93+
'is_require' => 1,
94+
'sort_order' => 0,
95+
'price' => 2,
96+
'price_type' => 'fixed',
97+
'sku' => '2-date',
98+
],
99+
[
100+
'previous_group' => 'select',
101+
'title' => 'Test Select',
102+
'type' => 'drop_down',
103+
'is_require' => 1,
104+
'sort_order' => 0,
105+
'values' => [
106+
[
107+
'option_type_id' => -1,
108+
'title' => 'Option 1',
109+
'price' => 3,
110+
'price_type' => 'fixed',
111+
'sku' => '3-1-select',
112+
],
113+
[
114+
'option_type_id' => -1,
115+
'title' => 'Option 2',
116+
'price' => 3,
117+
'price_type' => 'fixed',
118+
'sku' => '3-2-select',
119+
],
120+
]
121+
],
122+
[
123+
'previous_group' => 'select',
124+
'title' => 'Test Radio',
125+
'type' => 'radio',
126+
'is_require' => 1,
127+
'sort_order' => 0,
128+
'values' => [
129+
[
130+
'option_type_id' => -1,
131+
'title' => 'Option 1',
132+
'price' => 3,
133+
'price_type' => 'fixed',
134+
'sku' => '4-1-radio',
135+
],
136+
[
137+
'option_type_id' => -1,
138+
'title' => 'Option 2',
139+
'price' => 3,
140+
'price_type' => 'fixed',
141+
'sku' => '4-2-radio',
142+
],
143+
]
144+
]
145+
];
146+
147+
$options = [];
148+
149+
/** @var ProductCustomOptionInterfaceFactory $customOptionFactory */
150+
$customOptionFactory = $objectManager->create(ProductCustomOptionInterfaceFactory::class);
151+
152+
foreach ($oldOptions as $option) {
153+
/** @var ProductCustomOptionInterface $option */
154+
$option = $customOptionFactory->create(['data' => $option]);
155+
$option->setProductSku($product->getSku());
156+
157+
$options[] = $option;
158+
}
159+
160+
$product->setOptions($options);
161+
162+
/** @var ProductRepositoryInterface $productRepositoryFactory */
163+
$productRepositoryFactory = $objectManager->create(ProductRepositoryInterface::class);
164+
$productRepositoryFactory->save($product);
165+
166+
$categoryLinkManagement->assignProductToCategories(
167+
$product->getSku(),
168+
[2]
169+
);

0 commit comments

Comments
 (0)