diff --git a/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php b/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php index d751fdc75882d7514e282ad95908ffa74c86e65c..53c4605a819132df0791df60edb325ed5cf5837c 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php +++ b/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php @@ -542,19 +542,24 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract */ protected function processCountExistingPrices($prices, $table) { + $oldSkus = $this->retrieveOldSkus(); + $existProductIds = array_intersect_key($oldSkus, $prices); + if (!count($existProductIds)) { + return $this; + } + $tableName = $this->_resourceFactory->create()->getTable($table); $productEntityLinkField = $this->getProductEntityLinkField(); $existingPrices = $this->_connection->fetchAssoc( $this->_connection->select()->from( $tableName, ['value_id', $productEntityLinkField, 'all_groups', 'customer_group_id'] - ) + )->where($productEntityLinkField . ' IN (?)', $existProductIds) ); - $oldSkus = $this->retrieveOldSkus(); foreach ($existingPrices as $existingPrice) { - foreach ($oldSkus as $sku => $productId) { - if ($existingPrice[$productEntityLinkField] == $productId && isset($prices[$sku])) { - $this->incrementCounterUpdated($prices[$sku], $existingPrice); + foreach ($prices as $sku => $skuPrices) { + if (isset($oldSkus[$sku]) && $existingPrice[$productEntityLinkField] == $oldSkus[$sku]) { + $this->incrementCounterUpdated($skuPrices, $existingPrice); } } } diff --git a/app/code/Magento/Catalog/Model/Category/DataProvider.php b/app/code/Magento/Catalog/Model/Category/DataProvider.php index aefd31e21ad62f8469837a801581170581555c6a..8aa7216a6b63928ba9dcdd415b1745ed404321f1 100644 --- a/app/code/Magento/Catalog/Model/Category/DataProvider.php +++ b/app/code/Magento/Catalog/Model/Category/DataProvider.php @@ -5,12 +5,16 @@ */ namespace Magento\Catalog\Model\Category; +use Magento\Catalog\Api\Data\CategoryInterface; +use Magento\Catalog\Api\Data\EavAttributeInterface; +use Magento\Catalog\Model\Attribute\ScopeOverriddenValue; use Magento\Catalog\Model\Category; use Magento\Catalog\Model\ResourceModel\Eav\Attribute as EavAttribute; use Magento\Eav\Api\Data\AttributeInterface; use Magento\Eav\Model\Config; use Magento\Eav\Model\Entity\Type; use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory; +use Magento\Framework\Stdlib\ArrayManager; use Magento\Store\Model\Store; use Magento\Store\Model\StoreManagerInterface; use Magento\Ui\Component\Form\Field; @@ -112,6 +116,16 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider */ private $categoryFactory; + /** + * @var ScopeOverriddenValue + */ + private $scopeOverriddenValue; + + /** + * @var ArrayManager + */ + private $arrayManager; + /** * DataProvider constructor * @@ -151,8 +165,91 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider $this->storeManager = $storeManager; $this->request = $request; $this->categoryFactory = $categoryFactory; + parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data); - $this->meta = $this->prepareMeta($this->meta); + } + + /** + * @inheritdoc + */ + public function getMeta() + { + $meta = parent::getMeta(); + $meta = $this->prepareMeta($meta); + + $category = $this->getCurrentCategory(); + + if ($category) { + $meta = $this->addUseDefaultValueCheckbox($category, $meta); + $meta = $this->resolveParentInheritance($category, $meta); + } + + return $meta; + } + + /** + * @param Category $category + * @param array $meta + * @return array + */ + private function addUseDefaultValueCheckbox(Category $category, array $meta) + { + /** @var EavAttributeInterface $attribute */ + foreach ($category->getAttributes() as $attribute) { + $attributeCode = $attribute->getAttributeCode(); + $canDisplayUseDefault = $attribute->getScope() != EavAttributeInterface::SCOPE_GLOBAL_TEXT + && $category->getId() + && $category->getStoreId(); + $attributePath = $this->getArrayManager()->findPath($attributeCode, $meta); + + if ( + !$attributePath + || !$canDisplayUseDefault + || in_array($attributeCode, $this->elementsWithUseConfigSetting) + ) { + continue; + } + + $meta = $this->getArrayManager()->merge( + [$attributePath, 'arguments/data/config'], + $meta, + [ + 'service' => [ + 'template' => 'ui/form/element/helper/service', + ], + 'disabled' => !$this->getScopeOverriddenValue()->containsValue( + CategoryInterface::class, + $category, + $attributeCode, + $this->request->getParam($this->requestScopeFieldName, Store::DEFAULT_STORE_ID) + ) + ] + ); + } + + return $meta; + } + + /** + * Removes not necessary inheritance fields + * + * @param Category $category + * @param array $meta + * @return array + */ + private function resolveParentInheritance(Category $category, array $meta) + { + if (!$category->getParentId() || !$this->getArrayManager()->findPath('custom_use_parent_settings', $meta)) { + return $meta; + } + + $meta = $this->getArrayManager()->merge( + [$this->getArrayManager()->findPath('custom_use_parent_settings', $meta), 'arguments/data/config'], + $meta, + ['visible' => false] + ); + + return $meta; } /** @@ -204,7 +301,6 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider $category = $this->getCurrentCategory(); if ($category) { $categoryData = $category->getData(); - $categoryData = $this->addUseDefaultSettings($category, $categoryData); $categoryData = $this->addUseConfigSettings($categoryData); $categoryData = $this->filterFields($categoryData); $categoryData = $this->convertValues($category, $categoryData); @@ -292,6 +388,7 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider * @param \Magento\Catalog\Model\Category $category * @param array $categoryData * @return array + * @deprecated */ protected function addUseDefaultSettings($category, $categoryData) { @@ -406,15 +503,6 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider $result['use_config.available_sort_by']['default'] = true; $result['use_config.default_sort_by']['default'] = true; $result['use_config.filter_price_range']['default'] = true; - if ($this->request->getParam('store') && $this->request->getParam('id')) { - $result['use_default.url_key']['checked'] = true; - $result['use_default.url_key']['default'] = true; - $result['use_default.url_key']['visible'] = true; - } else { - $result['use_default.url_key']['checked'] = false; - $result['use_default.url_key']['default'] = false; - $result['use_default.url_key']['visible'] = false; - } return $result; } @@ -454,7 +542,6 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider [ 'url_key', 'url_key_create_redirect', - 'use_default.url_key', 'url_key_group', 'meta_title', 'meta_keywords', @@ -484,4 +571,38 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider ], ]; } + + /** + * Retrieve scope overridden value + * + * @return ScopeOverriddenValue + * @deprecated + */ + private function getScopeOverriddenValue() + { + if (null === $this->scopeOverriddenValue) { + $this->scopeOverriddenValue = \Magento\Framework\App\ObjectManager::getInstance()->get( + ScopeOverriddenValue::class + ); + } + + return $this->scopeOverriddenValue; + } + + /** + * Retrieve array manager + * + * @return ArrayManager + * @deprecated + */ + private function getArrayManager() + { + if (null === $this->arrayManager) { + $this->arrayManager = \Magento\Framework\App\ObjectManager::getInstance()->get( + ArrayManager::class + ); + } + + return $this->arrayManager; + } } diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml index 85793a2073d76224a467e97621766b079ffe63b3..4b99707b85f5cbdadc3e3b506aceab73a7940362 100644 --- a/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml +++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml @@ -375,19 +375,6 @@ <item name="source" xsi:type="string">category</item> <item name="label" xsi:type="string" translate="true">URL Key</item> <item name="sortOrder" xsi:type="number">10</item> - <item name="imports" xsi:type="array"> - <item name="disabled" xsi:type="string">${ $.provider }:data.use_default.url_key</item> - </item> - </item> - </argument> - </field> - <field name="use_default.url_key"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="description" xsi:type="string" translate="true">Use Default</item> - <item name="dataType" xsi:type="string">boolean</item> - <item name="formElement" xsi:type="string">checkbox</item> - <item name="sortOrder" xsi:type="number">20</item> </item> </argument> </field> @@ -453,10 +440,9 @@ <field name="custom_use_parent_settings"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="additionalClasses" xsi:type="string">admin__field-no-label</item> + <item name="additionalClasses" xsi:type="string">admin__field-x-small</item> <item name="sortOrder" xsi:type="number">170</item> - <item name="label" xsi:type="string"/> - <item name="description" xsi:type="string" translate="true">Use Parent Category Settings</item> + <item name="label" xsi:type="string">Use Parent Category Settings</item> <item name="dataType" xsi:type="string">boolean</item> <item name="formElement" xsi:type="string">checkbox</item> <item name="valueMap" xsi:type="array"> @@ -464,6 +450,8 @@ <item name="false" xsi:type="string">0</item> </item> <item name="default" xsi:type="string">0</item> + <item name="component" xsi:type="string">Magento_Ui/js/form/element/single-checkbox</item> + <item name="prefer" xsi:type="string">toggle</item> </item> </argument> </field> @@ -509,20 +497,21 @@ <field name="custom_apply_to_products"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="additionalClasses" xsi:type="string">admin__field-no-label</item> + <item name="additionalClasses" xsi:type="string">admin__field-x-small</item> <item name="sortOrder" xsi:type="number">210</item> - <item name="label" xsi:type="string"/> - <item name="description" xsi:type="string" translate="true">Apply Design to Products</item> + <item name="label" xsi:type="string" translate="true">Apply Design to Products</item> <item name="dataType" xsi:type="string">boolean</item> <item name="formElement" xsi:type="string">checkbox</item> - <item name="imports" xsi:type="array"> - <item name="disabled" xsi:type="string">ns = ${ $.ns }, index = custom_use_parent_settings :checked</item> - </item> <item name="valueMap" xsi:type="array"> <item name="true" xsi:type="string">1</item> <item name="false" xsi:type="string">0</item> </item> <item name="default" xsi:type="string">0</item> + <item name="component" xsi:type="string">Magento_Ui/js/form/element/single-checkbox</item> + <item name="prefer" xsi:type="string">toggle</item> + <item name="imports" xsi:type="array"> + <item name="disabled" xsi:type="string">ns = ${ $.ns }, index = custom_use_parent_settings:checked</item> + </item> </item> </argument> </field> diff --git a/app/code/Magento/Developer/Model/Logger/Handler/Debug.php b/app/code/Magento/Developer/Model/Logger/Handler/Debug.php index e05f008f70aa80a47f2eb8a6094d0f2ca3292671..cdf2403fa40a861a68b09b1112cd8885011ea92f 100644 --- a/app/code/Magento/Developer/Model/Logger/Handler/Debug.php +++ b/app/code/Magento/Developer/Model/Logger/Handler/Debug.php @@ -9,6 +9,7 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\State; use Magento\Framework\Filesystem\DriverInterface; use Magento\Store\Model\ScopeInterface; +use Magento\Framework\App\DeploymentConfig; /** * Class Debug @@ -25,22 +26,30 @@ class Debug extends \Magento\Framework\Logger\Handler\Debug */ private $scopeConfig; + /** + * @var DeploymentConfig + */ + private $deploymentConfig; + /** * @param DriverInterface $filesystem * @param State $state * @param ScopeConfigInterface $scopeConfig + * @param DeploymentConfig $deploymentConfig * @param string $filePath */ public function __construct( DriverInterface $filesystem, State $state, ScopeConfigInterface $scopeConfig, + DeploymentConfig $deploymentConfig, $filePath = null ) { parent::__construct($filesystem, $filePath); $this->state = $state; $this->scopeConfig = $scopeConfig; + $this->deploymentConfig = $deploymentConfig; } /** @@ -48,9 +57,13 @@ class Debug extends \Magento\Framework\Logger\Handler\Debug */ public function isHandling(array $record) { - return - parent::isHandling($record) - && $this->state->getMode() !== State::MODE_PRODUCTION - && $this->scopeConfig->getValue('dev/debug/debug_logging', ScopeInterface::SCOPE_STORE); + if ($this->deploymentConfig->isAvailable()) { + return + parent::isHandling($record) + && $this->state->getMode() !== State::MODE_PRODUCTION + && $this->scopeConfig->getValue('dev/debug/debug_logging', ScopeInterface::SCOPE_STORE); + } + + return parent::isHandling($record); } -} \ No newline at end of file +} diff --git a/app/code/Magento/Developer/Test/Unit/Model/Logger/Handler/DebugTest.php b/app/code/Magento/Developer/Test/Unit/Model/Logger/Handler/DebugTest.php index 7eae4020e676884a4710549c959b8f774efe9e14..e539e6b1772b87182ee4c5bb763d262ca60386b8 100644 --- a/app/code/Magento/Developer/Test/Unit/Model/Logger/Handler/DebugTest.php +++ b/app/code/Magento/Developer/Test/Unit/Model/Logger/Handler/DebugTest.php @@ -13,9 +13,11 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Store\Model\ScopeInterface; use Monolog\Formatter\FormatterInterface; use Monolog\Logger; +use Magento\Framework\App\DeploymentConfig; /** * Class DebugTest + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class DebugTest extends \PHPUnit_Framework_TestCase { @@ -44,6 +46,11 @@ class DebugTest extends \PHPUnit_Framework_TestCase */ private $formatterMock; + /** + * @var DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject + */ + private $deploymentConfigMock; + protected function setUp() { $this->filesystemMock = $this->getMockBuilder(DriverInterface::class) @@ -55,6 +62,10 @@ class DebugTest extends \PHPUnit_Framework_TestCase ->getMockForAbstractClass(); $this->formatterMock = $this->getMockBuilder(FormatterInterface::class) ->getMockForAbstractClass(); + $this->deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class) + ->disableOriginalConstructor() + ->disableOriginalClone() + ->getMock(); $this->formatterMock->expects($this->any()) ->method('format') @@ -64,12 +75,16 @@ class DebugTest extends \PHPUnit_Framework_TestCase 'filesystem' => $this->filesystemMock, 'state' => $this->stateMock, 'scopeConfig' => $this->scopeConfigMock, + 'deploymentConfig' => $this->deploymentConfigMock ]); $this->model->setFormatter($this->formatterMock); } public function testHandle() { + $this->deploymentConfigMock->expects($this->once()) + ->method('isAvailable') + ->willReturn(true); $this->stateMock->expects($this->once()) ->method('getMode') ->willReturn(State::MODE_DEVELOPER); @@ -78,22 +93,28 @@ class DebugTest extends \PHPUnit_Framework_TestCase ->with('dev/debug/debug_logging', ScopeInterface::SCOPE_STORE, null) ->willReturn(true); - $this->model->handle(['formatted' => false, 'level' => Logger::DEBUG]); + $this->assertTrue($this->model->isHandling(['formatted' => false, 'level' => Logger::DEBUG])); } public function testHandleDisabledByProduction() { + $this->deploymentConfigMock->expects($this->once()) + ->method('isAvailable') + ->willReturn(true); $this->stateMock->expects($this->once()) ->method('getMode') ->willReturn(State::MODE_PRODUCTION); $this->scopeConfigMock->expects($this->never()) ->method('getValue'); - $this->model->handle(['formatted' => false, 'level' => Logger::DEBUG]); + $this->assertFalse($this->model->isHandling(['formatted' => false, 'level' => Logger::DEBUG])); } public function testHandleDisabledByConfig() { + $this->deploymentConfigMock->expects($this->once()) + ->method('isAvailable') + ->willReturn(true); $this->stateMock->expects($this->once()) ->method('getMode') ->willReturn(State::MODE_DEVELOPER); @@ -102,16 +123,32 @@ class DebugTest extends \PHPUnit_Framework_TestCase ->with('dev/debug/debug_logging', ScopeInterface::SCOPE_STORE, null) ->willReturn(false); - $this->model->handle(['formatted' => false, 'level' => Logger::DEBUG]); + $this->assertFalse($this->model->isHandling(['formatted' => false, 'level' => Logger::DEBUG])); } public function testHandleDisabledByLevel() { + $this->deploymentConfigMock->expects($this->once()) + ->method('isAvailable') + ->willReturn(true); + $this->stateMock->expects($this->never()) + ->method('getMode'); + $this->scopeConfigMock->expects($this->never()) + ->method('getValue'); + + $this->assertFalse($this->model->isHandling(['formatted' => false, 'level' => Logger::API])); + } + + public function testDeploymentConfigIsNotAvailable() + { + $this->deploymentConfigMock->expects($this->once()) + ->method('isAvailable') + ->willReturn(false); $this->stateMock->expects($this->never()) ->method('getMode'); $this->scopeConfigMock->expects($this->never()) ->method('getValue'); - $this->model->handle(['formatted' => false, 'level' => Logger::API]); + $this->assertTrue($this->model->isHandling(['formatted' => false, 'level' => Logger::DEBUG])); } } diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/create/billing/method/form.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/create/billing/method/form.phtml index 6d09c4d7601890d4948c5d40fb801b51371bd57f..4a9af33449b61c80b709998cf663b5601df26447 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/create/billing/method/form.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/create/billing/method/form.phtml @@ -40,9 +40,7 @@ </div> <script> require(["Magento_Sales/order/create/form"], function(){ - <?php if($_methodsCount == 1):?> - order.switchPaymentMethod('<?php /* @escapeNotVerified */ echo $block->getSelectedMethodCode(); ?>'); - <?php else: ?> + <?php if($_methodsCount != 1):?> order.setPaymentMethod('<?php /* @escapeNotVerified */ echo $block->getSelectedMethodCode(); ?>'); <?php endif; ?> }); diff --git a/app/code/Magento/SalesInventory/composer.json b/app/code/Magento/SalesInventory/composer.json index d7f9075cdd310141bab6b25869f33d6229f513dc..fa06db402a286f5f37b2b1991d2c8c49665bd1d8 100644 --- a/app/code/Magento/SalesInventory/composer.json +++ b/app/code/Magento/SalesInventory/composer.json @@ -6,7 +6,7 @@ "magento/module-catalog-inventory": "100.2.*", "magento/module-sales": "100.2.*", "magento/module-store": "100.2.*", - "magento/module-catalog": "101.2.*", + "magento/module-catalog": "101.1.*", "magento/framework": "100.2.*" }, "type": "magento2-module", diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/file-uploader.js b/app/code/Magento/Ui/view/base/web/js/form/element/file-uploader.js index 917dc62f9f49b148d58ad62c671eb6fbeeff8beb..32ebd40f75346afb4d2d06cd6f9c4db16950fd4a 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/file-uploader.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/file-uploader.js @@ -72,6 +72,7 @@ define([ this.value(value); this.on('value', this.onUpdate.bind(this)); + this.isUseDefault(this.disabled()); return this; }, diff --git a/app/code/Magento/Ui/view/base/web/templates/form/element/uploader/uploader.html b/app/code/Magento/Ui/view/base/web/templates/form/element/uploader/uploader.html index 63c34c1a433129ddf427ecd8104743083a81e98b..ab309026c9ffeb3a8e56816c19994b33d34d4116 100644 --- a/app/code/Magento/Ui/view/base/web/templates/form/element/uploader/uploader.html +++ b/app/code/Magento/Ui/view/base/web/templates/form/element/uploader/uploader.html @@ -29,5 +29,6 @@ <each args="data: value, as: '$file'" render="$parent.getPreviewTmpl($file)"/> </div> + <render args="$data.service.template" if="$data.hasService()"/> </div> -</div> \ No newline at end of file +</div> diff --git a/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php b/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php index ecfb67320cb0d58decdf67de64d2058814f1eaf8..bae8f7c118c08b298bdc17b86db65181af075c3a 100644 --- a/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php +++ b/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php @@ -276,8 +276,8 @@ class PluginList extends Scoped implements InterceptionPluginList $data = $this->_cache->load($cacheId); if ($data) { list($this->_data, $this->_inherited, $this->_processed) = unserialize($data); - foreach ($this->_scopePriorityScheme as $scope) { - $this->_loadedScopes[$scope] = true; + foreach ($this->_scopePriorityScheme as $scopeCode) { + $this->_loadedScopes[$scopeCode] = true; } } else { $virtualTypes = []; @@ -285,18 +285,17 @@ class PluginList extends Scoped implements InterceptionPluginList if (false == isset($this->_loadedScopes[$scopeCode])) { $data = $this->_reader->read($scopeCode); unset($data['preferences']); - if (!count($data)) { - continue; - } - $this->_inherited = []; - $this->_processed = []; - $this->merge($data); - $this->_loadedScopes[$scopeCode] = true; - foreach ($data as $class => $config) { - if (isset($config['type'])) { - $virtualTypes[] = $class; + if (count($data) > 0) { + $this->_inherited = []; + $this->_processed = []; + $this->merge($data); + foreach ($data as $class => $config) { + if (isset($config['type'])) { + $virtualTypes[] = $class; + } } } + $this->_loadedScopes[$scopeCode] = true; } if ($this->isCurrentScope($scopeCode)) { break; diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php b/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php index b3fe011a0a490727c0682f1863aa731622753264..ac1e510f28b226a9c6386a35ca31192b7900cdc4 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php @@ -256,4 +256,33 @@ class PluginListTest extends \PHPUnit_Framework_TestCase $this->assertEquals(null, $this->_model->getNext('Type', 'method')); } + + /** + * @covers \Magento\Framework\Interception\PluginList\PluginList::getNext + * @covers \Magento\Framework\Interception\PluginList\PluginList::_loadScopedData + */ + public function testLoadScopeDataWithEmptyData() + { + $this->_objectManagerMock->expects($this->any()) + ->method('get') + ->will($this->returnArgument(0)); + $this->_configScopeMock->expects($this->any()) + ->method('getCurrentScope') + ->will($this->returnValue('emptyscope')); + + $this->assertEquals( + [4 => ['simple_plugin']], + $this->_model->getNext( + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class, + 'getName' + ) + ); + $this->assertEquals( + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemPlugin\Simple::class, + $this->_model->getPlugin( + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class, + 'simple_plugin' + ) + ); + } } diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/_files/reader_mock_map.php b/lib/internal/Magento/Framework/Interception/Test/Unit/_files/reader_mock_map.php index 87bbe0d35dd2561799cd5d2024347c8fb48c2b73..37c5316171fde594cacc8d3e3976c6d6aab95cde 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/_files/reader_mock_map.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/_files/reader_mock_map.php @@ -77,5 +77,11 @@ return [ ], ] ] + ], + [ + 'emptyscope', + [ + + ] ] ]; diff --git a/lib/internal/Magento/Framework/Test/Unit/ObjectManager/Config/CompiledTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/CompiledTest.php similarity index 98% rename from lib/internal/Magento/Framework/Test/Unit/ObjectManager/Config/CompiledTest.php rename to lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/CompiledTest.php index 3dd9f5065a1421ec822d4a81377ea81a5c3f8f52..1fcf3176540db6279e3fec6754fb3a7a22b3cc59 100644 --- a/lib/internal/Magento/Framework/Test/Unit/ObjectManager/Config/CompiledTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/CompiledTest.php @@ -3,7 +3,7 @@ * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Test\Unit\ObjectManager\Config; +namespace Magento\Framework\ObjectManager\Test\Unit\Config; use Magento\Framework\ObjectManager\Config\Compiled as CompiledConfig; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; diff --git a/lib/internal/Magento/Framework/Stdlib/ArrayManager.php b/lib/internal/Magento/Framework/Stdlib/ArrayManager.php index f8b758bb9d9dfa480fd3657cee0ea3ed6c0b0f81..edce214cc3091d55ba27ca382fed2fc201a11731 100644 --- a/lib/internal/Magento/Framework/Stdlib/ArrayManager.php +++ b/lib/internal/Magento/Framework/Stdlib/ArrayManager.php @@ -30,7 +30,7 @@ class ArrayManager /** * Check if node exists * - * @param string $path + * @param array|string $path * @param array $data * @param string $delimiter * @return bool @@ -43,7 +43,7 @@ class ArrayManager /** * Retrieve node * - * @param string $path + * @param array|string $path * @param array $data * @param null $defaultValue * @param string $delimiter @@ -57,7 +57,7 @@ class ArrayManager /** * Set value into node and return modified data * - * @param string $path + * @param array|string $path * @param array $data * @param mixed $value * @param string $delimiter @@ -75,7 +75,7 @@ class ArrayManager /** * Set value into existing node and return modified data * - * @param string $path + * @param array|string $path * @param array $data * @param mixed $value * @param string $delimiter @@ -93,7 +93,7 @@ class ArrayManager /** * Move value from one location to another * - * @param string $path + * @param array|string $path * @param string $targetPath * @param array $data * @param bool $overwrite @@ -120,7 +120,7 @@ class ArrayManager /** * Merge value with node and return modified data * - * @param string $path + * @param array|string $path * @param array $data * @param array $value * @param string $delimiter @@ -141,7 +141,7 @@ class ArrayManager /** * Populate nested array if possible and needed * - * @param string $path + * @param array|string $path * @param array $data * @param string $delimiter * @return array @@ -156,7 +156,7 @@ class ArrayManager /** * Remove node and return modified data * - * @param string $path + * @param array|string $path * @param array $data * @param string $delimiter * @return array @@ -173,7 +173,7 @@ class ArrayManager /** * Finds node in nested array and saves its index and parent node reference * - * @param string $path + * @param array|string $path * @param array $data * @param string $delimiter * @param bool $populate @@ -181,6 +181,10 @@ class ArrayManager */ protected function find($path, array &$data, $delimiter, $populate = false) { + if (is_array($path)) { + $path = implode($delimiter, $path); + } + if ($path === null) { return false; } diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/ArrayManagerTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/ArrayManagerTest.php index 4d469236e64bb8d9bd4265103814c37abcdbf047..9ba8dbcf789857863794a1a1ea99b6c47368e477 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/ArrayManagerTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/ArrayManagerTest.php @@ -139,6 +139,12 @@ class ArrayManagerTest extends \PHPUnit_Framework_TestCase 'data' => ['existing' => ['path' => 1]], 'value' => 'valuable data', 'result' => ['existing' => ['path' => 1], 'new' => ['path' => [2 => 'valuable data']]] + ], + 3 => [ + 'path' => ['new', 'path/2'], + 'data' => ['existing' => ['path' => 1]], + 'value' => 'valuable data', + 'result' => ['existing' => ['path' => 1], 'new' => ['path' => [2 => 'valuable data']]] ] ]; } @@ -178,6 +184,12 @@ class ArrayManagerTest extends \PHPUnit_Framework_TestCase 'data' => ['existing' => ['path' => 1]], 'value' => 'valuable data', 'result' => ['existing' => ['path' => 1]] + ], + 3 => [ + 'path' => ['new', 'path', '2'], + 'data' => ['existing' => ['path' => 1]], + 'value' => 'valuable data', + 'result' => ['existing' => ['path' => 1]] ] ]; } @@ -228,6 +240,13 @@ class ArrayManagerTest extends \PHPUnit_Framework_TestCase 'data' => ['valid' => ['path' => 'value'], 'target' => ['path' => 'exists']], 'overwrite' => true, 'result' => ['valid' => [], 'target' => ['path' => 'value']] + ], + 4 => [ + 'path' => ['valid', 'path'], + 'targetPath' => 'target/path', + 'data' => ['valid' => ['path' => 'value'], 'target' => ['path' => 'exists']], + 'overwrite' => true, + 'result' => ['valid' => [], 'target' => ['path' => 'value']] ] ]; } @@ -267,7 +286,13 @@ class ArrayManagerTest extends \PHPUnit_Framework_TestCase 'data' => [], 'value' => [true], 'result' => [] - ] + ], + 3 => [ + 'path' => ['0', 'path/1'], + 'data' => [['path' => [false, ['value' => false]]]], + 'value' => ['value' => true, 'new_value' => false], + 'result' => [['path' => [false, ['value' => true, 'new_value' => false]]]] + ], ]; } @@ -337,7 +362,12 @@ class ArrayManagerTest extends \PHPUnit_Framework_TestCase 'path' => 'invalid', 'data' => [true], 'result' => [true] - ] + ], + 3 => [ + 'path' => ['simple'], + 'data' => ['simple' => true, 'complex' => false], + 'result' => ['complex' => false] + ], ]; } @@ -550,7 +580,7 @@ class ArrayManagerTest extends \PHPUnit_Framework_TestCase 'offset' => -6, 'length' => 3, 'result' => 'path/0/goes' - ] + ], ]; }