Skip to content

Commit 01ebb84

Browse files
author
Alexander Paliarush
committed
Merge remote-tracking branch 'remotes/origin/MAGETWO-53159-Country-of-Manufacture' into API-Bug-Fixes
2 parents 41550fe + 10a3074 commit 01ebb84

File tree

7 files changed

+90
-11
lines changed

7 files changed

+90
-11
lines changed

app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,11 @@ public function getAllOptions()
6363
if ($cache = $this->_configCacheType->load($cacheKey)) {
6464
$options = unserialize($cache);
6565
} else {
66-
$collection = $this->_countryFactory->create()->getResourceCollection()->loadByStore();
67-
$options = $collection->toOptionArray();
66+
/** @var \Magento\Directory\Model\Country $country */
67+
$country = $this->_countryFactory->create();
68+
/** @var \Magento\Directory\Model\ResourceModel\Country\Collection $collection */
69+
$collection = $country->getResourceCollection();
70+
$options = $collection->load()->toOptionArray();
6871
$this->_configCacheType->save(serialize($options), $cacheKey);
6972
}
7073
return $options;

dev/tests/functional/tests/app/Magento/Backend/Test/Repository/ConfigData.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,23 @@
194194
<item name="value" xsi:type="number">0</item>
195195
</field>
196196
</dataset>
197+
198+
<dataset name="custom_allowed_country">
199+
<field name="general/country/allow" xsi:type="array">
200+
<item name="scope" xsi:type="string">default</item>
201+
<item name="scope_id" xsi:type="number">0</item>
202+
<item name="value" xsi:type="array">
203+
<item name="Albania" xsi:type="string">AL</item>
204+
<item name="United States" xsi:type="string">US</item>
205+
</item>
206+
</field>
207+
</dataset>
208+
<dataset name="custom_allowed_country_rollback">
209+
<field name="general/country/allow" xsi:type="array">
210+
<item name="scope" xsi:type="string">default</item>
211+
<item name="scope_id" xsi:type="number">0</item>
212+
<item name="inherit" xsi:type="string">1</item>
213+
</field>
214+
</dataset>
197215
</repository>
198216
</config>

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
<selector>[name="product[news_to_date]"]</selector>
5151
<strategy>css selector</strategy>
5252
</news_to_date>
53+
<country_of_manufacture>
54+
<input>select</input>
55+
</country_of_manufacture>
5356
</fields>
5457
</product-details>
5558
<advanced-pricing>

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ class CreateSimpleProductEntityTest extends Injectable
3939
*/
4040
protected $configData;
4141

42+
/**
43+
* Should cache be flushed
44+
*
45+
* @var bool
46+
*/
47+
private $flushCache;
48+
4249
/**
4350
* Prepare data.
4451
*
@@ -62,21 +69,24 @@ public function __prepare(Category $category)
6269
* @param CatalogProductIndex $productGrid
6370
* @param CatalogProductNew $newProductPage
6471
* @param string $configData
72+
* @param bool $flushCache
6573
* @return array
6674
*/
6775
public function testCreate(
6876
CatalogProductSimple $product,
6977
Category $category,
7078
CatalogProductIndex $productGrid,
7179
CatalogProductNew $newProductPage,
80+
$flushCache = false,
7281
$configData = null
7382
) {
7483
$this->configData = $configData;
84+
$this->flushCache = $flushCache;
7585

7686
// Preconditions
7787
$this->objectManager->create(
78-
'Magento\Config\Test\TestStep\SetupConfigurationStep',
79-
['configData' => $this->configData]
88+
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
89+
['configData' => $this->configData, 'flushCache' => $this->flushCache]
8090
)->run();
8191

8292
// Steps
@@ -96,8 +106,8 @@ public function testCreate(
96106
public function tearDown()
97107
{
98108
$this->objectManager->create(
99-
'Magento\Config\Test\TestStep\SetupConfigurationStep',
100-
['configData' => $this->configData, 'rollback' => true]
109+
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
110+
['configData' => $this->configData, 'rollback' => true, 'flushCache' => $this->flushCache]
101111
)->run();
102112
}
103113
}

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,5 +447,19 @@
447447
<constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" />
448448
<constraint name="Magento\Catalog\Test\Constraint\AssertProductInCategory" />
449449
</variation>
450+
<variation name="CreateSimpleProductEntityTestVariation27" summary="Create Simple Product with custom Country of manufacture" ticketId="MAGETWO-55336">
451+
<data name="configData" xsi:type="string">custom_allowed_country</data>
452+
<data name="flushCache" xsi:type="boolean">true</data>
453+
<data name="product/data/url_key" xsi:type="string">simple-product-%isolation%</data>
454+
<data name="product/data/name" xsi:type="string">Simple Product %isolation%</data>
455+
<data name="product/data/sku" xsi:type="string">simple_sku_%isolation%</data>
456+
<data name="product/data/price/value" xsi:type="string">10000</data>
457+
<data name="product/data/short_description" xsi:type="string">Simple Product short_description %isolation%</data>
458+
<data name="product/data/description" xsi:type="string">Simple Product description %isolation%</data>
459+
<data name="product/data/weight" xsi:type="string">50</data>
460+
<data name="product/data/quantity_and_stock_status/qty" xsi:type="string">657</data>
461+
<data name="product/data/country_of_manufacture" xsi:type="string">Antarctica</data>
462+
<constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" />
463+
</variation>
450464
</testCase>
451465
</config>

dev/tests/functional/tests/app/Magento/Config/Test/Handler/ConfigData/Curl.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,16 @@ protected function prepareConfigPath(array $input)
8989
}
9090
$resultArray .= '[' . $subPath . ']';
9191
}
92-
$resultArray .= '[value]';
93-
if (is_array($input['value'])) {
92+
$valueCode = isset($input['inherit']) ? 'inherit' : 'value';
93+
$resultArray .= "[$valueCode]";
94+
if (isset($input['value']) && is_array($input['value'])) {
9495
$values = [];
9596
foreach ($input['value'] as $key => $value) {
9697
$values[] = $resultArray . "[$key]=$value";
9798
}
9899
$resultArray = implode('&', $values);
99100
} else {
100-
$resultArray .= '=' . $input['value'];
101+
$resultArray .= '=' . $input[$valueCode];
101102
}
102103
return $resultArray;
103104
}

dev/tests/functional/tests/app/Magento/Config/Test/TestStep/SetupConfigurationStep.php

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Magento\Mtf\Fixture\FixtureFactory;
1010
use Magento\Mtf\TestStep\TestStepInterface;
11+
use Magento\PageCache\Test\Page\Adminhtml\AdminCache;
1112

1213
/**
1314
* Setup configuration using handler.
@@ -21,6 +22,13 @@ class SetupConfigurationStep implements TestStepInterface
2122
*/
2223
protected $fixtureFactory;
2324

25+
/**
26+
* Admin cache page.
27+
*
28+
* @var AdminCache
29+
*/
30+
private $adminCache;
31+
2432
/**
2533
* Configuration data.
2634
*
@@ -35,19 +43,35 @@ class SetupConfigurationStep implements TestStepInterface
3543
*/
3644
protected $rollback;
3745

46+
/**
47+
* Flush cache.
48+
*
49+
* @var bool
50+
*/
51+
protected $flushCache;
52+
3853
/**
3954
* Preparing step properties.
4055
*
4156
* @constructor
4257
* @param FixtureFactory $fixtureFactory
58+
* @param AdminCache $adminCache
4359
* @param string $configData
4460
* @param bool $rollback
61+
* @param bool $flushCache
4562
*/
46-
public function __construct(FixtureFactory $fixtureFactory, $configData = null, $rollback = false)
47-
{
63+
public function __construct(
64+
FixtureFactory $fixtureFactory,
65+
AdminCache $adminCache,
66+
$configData = null,
67+
$rollback = false,
68+
$flushCache = false
69+
) {
4870
$this->fixtureFactory = $fixtureFactory;
71+
$this->adminCache = $adminCache;
4972
$this->configData = $configData;
5073
$this->rollback = $rollback;
74+
$this->flushCache = $flushCache;
5175
}
5276

5377
/**
@@ -72,6 +96,12 @@ public function run()
7296
$result[] = $config;
7397
}
7498
}
99+
100+
if ($this->flushCache) {
101+
$this->adminCache->open();
102+
$this->adminCache->getActionsBlock()->flushMagentoCache();
103+
$this->adminCache->getMessagesBlock()->waitSuccessMessage();
104+
}
75105

76106
return ['config' => $result];
77107
}

0 commit comments

Comments
 (0)