Skip to content

Commit ffaaf5c

Browse files
author
Bohdan Korablov
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-61744
2 parents a4a5c9a + d166004 commit ffaaf5c

File tree

11 files changed

+165
-43
lines changed

11 files changed

+165
-43
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,5 @@ atlassian*
5151
!/var/.htaccess
5252
/vendor/*
5353
!/vendor/.htaccess
54+
/generated/*
55+
!/generated/.htaccess

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"phpunit/phpunit": "4.1.0",
7373
"squizlabs/php_codesniffer": "1.5.3",
7474
"phpmd/phpmd": "@stable",
75-
"pdepend/pdepend": "2.2.2",
75+
"pdepend/pdepend": "2.4.0",
7676
"friendsofphp/php-cs-fixer": "~1.2",
7777
"lusitanian/oauth": "~0.3 <=0.7.0",
7878
"sebastian/phpcpd": "2.0.0"

composer.lock

Lines changed: 39 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,6 @@
9191
<field name="product_has_weight" group="product-details" />
9292
<field name="attributes" />
9393
<field name="fpt" is_required="0" group="product-details" repository="Magento\Catalog\Test\Repository\Product\Fpt" />
94+
<field name="website_data" is_required="0" repository="Magento\Catalog\Test\Repository\CatalogProductSimple\WebsiteData" />
9495
</fixture>
9596
</config>

dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Webapi.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,38 @@ public function persist(FixtureInterface $fixture = null)
107107
throw new \Exception("Product creation by webapi handler was not successful! Response: {$encodedResponse}");
108108
}
109109

110+
$this->updateProduct($fixture);
110111
return $this->parseResponse($response);
111112
}
112113

114+
/**
115+
* Update product info per website.
116+
*
117+
* @param FixtureInterface $fixture
118+
* @return void
119+
* @throws \Exception
120+
*/
121+
private function updateProduct(FixtureInterface $fixture)
122+
{
123+
if (isset($fixture->getData()['website_data'])) {
124+
$websiteData = $fixture->getData()['website_data'];
125+
foreach ($fixture->getDataFieldConfig('website_ids')['source']->getStores() as $key => $store) {
126+
$url = $_ENV['app_frontend_url'] . 'rest/' . $store->getCode() . '/V1/products/' . $fixture->getSku();
127+
$this->webapiTransport->write($url, ['product' => $websiteData[$key]], CurlInterface::PUT);
128+
$encodedResponse = $this->webapiTransport->read();
129+
$response = json_decode($encodedResponse, true);
130+
$this->webapiTransport->close();
131+
132+
if (!isset($response['id'])) {
133+
$this->eventManager->dispatchEvent(['webapi_failed'], [$response]);
134+
throw new \Exception(
135+
"Product update by webapi handler was not successful! Response: {$encodedResponse}"
136+
);
137+
}
138+
}
139+
}
140+
}
141+
113142
/**
114143
* Prepare data for creating product request.
115144
*

dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,5 +1856,38 @@
18561856
</field>
18571857
<field name="url_key" xsi:type="string">simple-product-%isolation%</field>
18581858
</dataset>
1859+
1860+
<dataset name="product_with_additional_website_and_custom_price">
1861+
<field name="sku" xsi:type="string">simple_product_with_category_%isolation%</field>
1862+
<field name="name" xsi:type="string">Simple product with category %isolation%</field>
1863+
<field name="quantity_and_stock_status" xsi:type="array">
1864+
<item name="qty" xsi:type="string">777</item>
1865+
<item name="is_in_stock" xsi:type="string">In Stock</item>
1866+
</field>
1867+
<field name="product_has_weight" xsi:type="string">This item has weight</field>
1868+
<field name="weight" xsi:type="string">1</field>
1869+
<field name="attribute_set_id" xsi:type="array">
1870+
<item name="dataset" xsi:type="string">default</item>
1871+
</field>
1872+
<field name="price" xsi:type="array">
1873+
<item name="value" xsi:type="string">10</item>
1874+
<item name="dataset" xsi:type="string" />
1875+
</field>
1876+
<field name="category_ids" xsi:type="array">
1877+
<item name="dataset" xsi:type="string">default_subcategory</item>
1878+
</field>
1879+
<field name="website_ids" xsi:type="array">
1880+
<item name="0" xsi:type="array">
1881+
<item name="dataset" xsi:type="string">default</item>
1882+
</item>
1883+
<item name="1" xsi:type="array">
1884+
<item name="dataset" xsi:type="string">custom_store</item>
1885+
</item>
1886+
</field>
1887+
<field name="url_key" xsi:type="string">simple-product-%isolation%</field>
1888+
<field name="website_data" xsi:type="array">
1889+
<item name="dataset" xsi:type="string">custom_price_in_main_and_custom_websites</item>
1890+
</field>
1891+
</dataset>
18591892
</repository>
18601893
</config>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" ?>
2+
<!--
3+
/**
4+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
9+
<repository class="Magento\Catalog\Test\Repository\CatalogProductSimple\WebsiteData">
10+
<dataset name="custom_price_in_main_and_custom_websites">
11+
<field name="0" xsi:type="array">
12+
<item name="price" xsi:type="number">15</item>
13+
</field>
14+
<field name="1" xsi:type="array">
15+
<item name="price" xsi:type="number">20</item>
16+
</field>
17+
</dataset>
18+
</repository>
19+
</config>

lib/internal/Magento/Framework/App/Filesystem/DirectoryList.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ class DirectoryList extends \Magento\Framework\Filesystem\DirectoryList
109109

110110
const TEMPLATE_MINIFICATION_DIR = 'html';
111111

112+
/**
113+
* Directory name for generated data.
114+
*/
115+
const GENERATED = 'generated';
116+
112117
/**
113118
* {@inheritdoc}
114119
*/
@@ -135,6 +140,7 @@ public static function getDefaultConfig()
135140
self::TEMPLATE_MINIFICATION_DIR => [parent::PATH => 'var/view_preprocessed/html'],
136141
self::SETUP => [parent::PATH => 'setup/src'],
137142
self::COMPOSER_HOME => [parent::PATH => 'var/composer_home'],
143+
self::GENERATED => [parent::PATH => 'generated'],
138144
];
139145
return parent::getDefaultConfig() + $result;
140146
}

lib/internal/Magento/Framework/App/Test/Unit/Filesystem/DirectoryListTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,31 @@ public function testUnknownDirectory()
3838
{
3939
new DirectoryList('/root/dir', ['test' => [DirectoryList::PATH => '/baz']]);
4040
}
41+
42+
public function testGetDefaultConfig()
43+
{
44+
$defaultConfig = DirectoryList::getDefaultConfig();
45+
46+
$this->assertArrayHasKey(DirectoryList::GENERATED, $defaultConfig);
47+
$this->assertArrayHasKey(DirectoryList::DI, $defaultConfig);
48+
$this->assertArrayHasKey(DirectoryList::GENERATION, $defaultConfig);
49+
$this->assertArrayHasKey(DirectoryList::ROOT, $defaultConfig);
50+
$this->assertArrayHasKey(DirectoryList::APP, $defaultConfig);
51+
$this->assertArrayHasKey(DirectoryList::CONFIG, $defaultConfig);
52+
$this->assertArrayHasKey(DirectoryList::LIB_INTERNAL, $defaultConfig);
53+
$this->assertArrayHasKey(DirectoryList::VAR_DIR, $defaultConfig);
54+
$this->assertArrayHasKey(DirectoryList::CACHE, $defaultConfig);
55+
$this->assertArrayHasKey(DirectoryList::LOG, $defaultConfig);
56+
$this->assertArrayHasKey(DirectoryList::SESSION, $defaultConfig);
57+
$this->assertArrayHasKey(DirectoryList::MEDIA, $defaultConfig);
58+
$this->assertArrayHasKey(DirectoryList::STATIC_VIEW, $defaultConfig);
59+
$this->assertArrayHasKey(DirectoryList::PUB, $defaultConfig);
60+
$this->assertArrayHasKey(DirectoryList::LIB_WEB, $defaultConfig);
61+
$this->assertArrayHasKey(DirectoryList::TMP, $defaultConfig);
62+
$this->assertArrayHasKey(DirectoryList::UPLOAD, $defaultConfig);
63+
$this->assertArrayHasKey(DirectoryList::TEMPLATE_MINIFICATION_DIR, $defaultConfig);
64+
$this->assertArrayHasKey(DirectoryList::TMP_MATERIALIZATION_DIR, $defaultConfig);
65+
$this->assertArrayHasKey(DirectoryList::SETUP, $defaultConfig);
66+
$this->assertArrayHasKey(DirectoryList::COMPOSER_HOME, $defaultConfig);
67+
}
4168
}

lib/internal/Magento/Framework/Setup/FilePermissions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public function getInstallationWritableDirectories()
8282
DirectoryList::VAR_DIR,
8383
DirectoryList::MEDIA,
8484
DirectoryList::STATIC_VIEW,
85+
DirectoryList::GENERATED,
8586
];
8687
foreach ($data as $code) {
8788
$this->installationWritableDirectories[$code] = $this->directoryList->getPath($code);

0 commit comments

Comments
 (0)