diff --git a/app/code/Magento/Backend/Model/Menu/Item.php b/app/code/Magento/Backend/Model/Menu/Item.php index 724ffb0aa744c..3914c8b4ba764 100644 --- a/app/code/Magento/Backend/Model/Menu/Item.php +++ b/app/code/Magento/Backend/Model/Menu/Item.php @@ -466,15 +466,15 @@ public function toArray() { return [ 'parent_id' => $this->_parentId, - 'module_name' => $this->_moduleName, + 'module' => $this->_moduleName, 'sort_index' => $this->_sortIndex, - 'depends_on_config' => $this->_dependsOnConfig, + 'dependsOnConfig' => $this->_dependsOnConfig, 'id' => $this->_id, 'resource' => $this->_resource, 'path' => $this->_path, 'action' => $this->_action, - 'depends_on_module' => $this->_dependsOnModule, - 'tooltip' => $this->_tooltip, + 'dependsOnModule' => $this->_dependsOnModule, + 'toolTip' => $this->_tooltip, 'title' => $this->_title, 'target' => $this->target, 'sub_menu' => isset($this->_submenu) ? $this->_submenu->toArray() : null @@ -491,15 +491,15 @@ public function toArray() public function populateFromArray(array $data) { $this->_parentId = $this->_getArgument($data, 'parent_id'); - $this->_moduleName = $this->_getArgument($data, 'module_name', 'Magento_Backend'); + $this->_moduleName = $this->_getArgument($data, 'module', 'Magento_Backend'); $this->_sortIndex = $this->_getArgument($data, 'sort_index'); - $this->_dependsOnConfig = $this->_getArgument($data, 'depends_on_config'); + $this->_dependsOnConfig = $this->_getArgument($data, 'dependsOnConfig'); $this->_id = $this->_getArgument($data, 'id'); $this->_resource = $this->_getArgument($data, 'resource'); $this->_path = $this->_getArgument($data, 'path', ''); $this->_action = $this->_getArgument($data, 'action'); - $this->_dependsOnModule = $this->_getArgument($data, 'depends_on_module'); - $this->_tooltip = $this->_getArgument($data, 'tooltip', ''); + $this->_dependsOnModule = $this->_getArgument($data, 'dependsOnModule'); + $this->_tooltip = $this->_getArgument($data, 'toolTip'); $this->_title = $this->_getArgument($data, 'title'); $this->target = $this->_getArgument($data, 'target'); if (isset($data['sub_menu'])) { diff --git a/app/code/Magento/Backend/Test/Unit/Model/Menu/ItemTest.php b/app/code/Magento/Backend/Test/Unit/Model/Menu/ItemTest.php index 74368537c39c7..ad172cbfbd165 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Menu/ItemTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Menu/ItemTest.php @@ -56,9 +56,9 @@ class ItemTest extends \PHPUnit\Framework\TestCase 'title' => 'Item Title', 'action' => '/system/config', 'resource' => 'Magento_Config::config', - 'depends_on_module' => 'Magento_Backend', - 'depends_on_config' => 'system/config/isEnabled', - 'tooltip' => 'Item tooltip', + 'dependsOnModule' => 'Magento_Backend', + 'dependsOnConfig' => 'system/config/isEnabled', + 'toolTip' => 'Item tooltip', ]; protected function setUp() diff --git a/app/code/Magento/Backend/Test/Unit/Model/_files/menu_item_constructor_data.php b/app/code/Magento/Backend/Test/Unit/Model/_files/menu_item_constructor_data.php index b0c74461980a2..82f07e264b963 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/_files/menu_item_constructor_data.php +++ b/app/code/Magento/Backend/Test/Unit/Model/_files/menu_item_constructor_data.php @@ -12,21 +12,21 @@ 'title' => 'Item Title', 'action' => '/system/config', 'resource' => 'Magento_Config::config', - 'depends_on_module' => 'Magento_Backend', - 'depends_on_config' => 'system/config/isEnabled', - 'tooltip' => 'Item tooltip', + 'dependsOnModule' => 'Magento_Backend', + 'dependsOnConfig' => 'system/config/isEnabled', + 'toolTip' => 'Item tooltip', ], [ 'parent_id' => null, - 'module_name' => 'Magento_Backend', + 'module' => 'Magento_Backend', 'sort_index' => null, - 'depends_on_config' => 'system/config/isEnabled', + 'dependsOnConfig' => 'system/config/isEnabled', 'id' => 'item', 'resource' => 'Magento_Config::config', 'path' => '', 'action' => '/system/config', - 'depends_on_module' => 'Magento_Backend', - 'tooltip' => 'Item tooltip', + 'dependsOnModule' => 'Magento_Backend', + 'toolTip' => 'Item tooltip', 'title' => 'Item Title', 'sub_menu' => null, 'target' => null @@ -38,43 +38,43 @@ 'title' => 'Item Title', 'action' => '/system/config', 'resource' => 'Magento_Config::config', - 'depends_on_module' => 'Magento_Backend', - 'depends_on_config' => 'system/config/isEnabled', - 'tooltip' => 'Item tooltip', + 'dependsOnModule' => 'Magento_Backend', + 'dependsOnConfig' => 'system/config/isEnabled', + 'toolTip' => 'Item tooltip', ], [ 'parent_id' => '1', - 'module_name' => 'Magento_Module1', + 'module' => 'Magento_Module1', 'sort_index' => '50', - 'depends_on_config' => null, + 'dependsOnConfig' => null, 'id' => '5', 'resource' => null, 'path' => null, 'action' => null, - 'depends_on_module' => null, - 'tooltip' => null, + 'dependsOnModule' => null, + 'toolTip' => null, 'title' => null, 'sub_menu' => [ 'id' => 'item', 'title' => 'Item Title', 'action' => '/system/config', 'resource' => 'Magento_Config::config', - 'depends_on_module' => 'Magento_Backend', - 'depends_on_config' => 'system/config/isEnabled', - 'tooltip' => 'Item tooltip', + 'dependsOnModule' => 'Magento_Backend', + 'dependsOnConfig' => 'system/config/isEnabled', + 'toolTip' => 'Item tooltip', ], ], [ 'parent_id' => '1', - 'module_name' => 'Magento_Module1', + 'module' => 'Magento_Module1', 'sort_index' => '50', - 'depends_on_config' => null, + 'dependsOnConfig' => null, 'id' => '5', 'resource' => null, 'path' => '', 'action' => null, - 'depends_on_module' => null, - 'tooltip' => '', + 'dependsOnModule' => null, + 'toolTip' => '', 'title' => null, 'sub_menu' => ['submenuArray'], 'target' => null @@ -83,51 +83,51 @@ 'data with submenu to constructor' => [ [ 'parent_id' => '1', - 'module_name' => 'Magento_Module1', + 'module' => 'Magento_Module1', 'sort_index' => '50', - 'depends_on_config' => null, + 'dependsOnConfig' => null, 'id' => '5', 'resource' => null, 'path' => null, 'action' => null, - 'depends_on_module' => null, - 'tooltip' => null, + 'dependsOnModule' => null, + 'toolTip' => null, 'title' => null, 'sub_menu' => [ 'id' => 'item', 'title' => 'Item Title', 'action' => '/system/config', 'resource' => 'Magento_Config::config', - 'depends_on_module' => 'Magento_Backend', - 'depends_on_config' => 'system/config/isEnabled', - 'tooltip' => 'Item tooltip', + 'dependsOnModule' => 'Magento_Backend', + 'dependsOnConfig' => 'system/config/isEnabled', + 'toolTip' => 'Item tooltip', ], ], [ 'parent_id' => '1', - 'module_name' => 'Magento_Module1', + 'module' => 'Magento_Module1', 'sort_index' => '50', 'sub_menu' => [ 'id' => 'item', 'title' => 'Item Title', 'action' => '/system/config', 'resource' => 'Magento_Config::config', - 'depends_on_module' => 'Magento_Backend', - 'depends_on_config' => 'system/config/isEnabled', - 'tooltip' => 'Item tooltip', + 'dependsOnModule' => 'Magento_Backend', + 'dependsOnConfig' => 'system/config/isEnabled', + 'toolTip' => 'Item tooltip', ], ], [ 'parent_id' => '1', - 'module_name' => 'Magento_Module1', + 'module' => 'Magento_Module1', 'sort_index' => '50', - 'depends_on_config' => null, + 'dependsOnConfig' => null, 'id' => null, 'resource' => null, 'path' => '', 'action' => null, - 'depends_on_module' => null, - 'tooltip' => '', + 'dependsOnModule' => null, + 'toolTip' => '', 'title' => null, 'sub_menu' => ['submenuArray'], 'target' => null diff --git a/app/code/Magento/Backend/Test/Unit/Model/_files/menu_item_data.php b/app/code/Magento/Backend/Test/Unit/Model/_files/menu_item_data.php index 30a43b0158ae3..b1a310d7d440b 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/_files/menu_item_data.php +++ b/app/code/Magento/Backend/Test/Unit/Model/_files/menu_item_data.php @@ -11,22 +11,22 @@ 'title' => 'Item Title', 'action' => '/system/config', 'resource' => 'Magento_Config::config', - 'depends_on_module' => 'Magento_Backend', - 'depends_on_config' => 'system/config/isEnabled', - 'tooltip' => 'Item tooltip', + 'dependsOnModule' => 'Magento_Backend', + 'dependsOnConfig' => 'system/config/isEnabled', + 'toolTip' => 'Item tooltip', 'sub_menu' => null, ], [ 'parent_id' => null, - 'module_name' => 'Magento_Backend', + 'module' => 'Magento_Backend', 'sort_index' => null, - 'depends_on_config' => 'system/config/isEnabled', + 'dependsOnConfig' => 'system/config/isEnabled', 'id' => 'item', 'resource' => 'Magento_Config::config', 'path' => '', 'action' => '/system/config', - 'depends_on_module' => 'Magento_Backend', - 'tooltip' => 'Item tooltip', + 'dependsOnModule' => 'Magento_Backend', + 'toolTip' => 'Item tooltip', 'title' => 'Item Title', 'sub_menu' => null, 'target' => null @@ -35,46 +35,46 @@ 'with submenu' => [ [ 'parent_id' => '1', - 'module_name' => 'Magento_Module1', + 'module' => 'Magento_Module1', 'sort_index' => '50', - 'depends_on_config' => null, + 'dependsOnConfig' => null, 'id' => '5', 'resource' => null, 'path' => null, 'action' => null, - 'depends_on_module' => null, - 'tooltip' => null, + 'dependsOnModule' => null, + 'toolTip' => null, 'title' => null, 'sub_menu' => [ 'id' => 'item', 'title' => 'Item Title', 'action' => '/system/config', 'resource' => 'Magento_Config::config', - 'depends_on_module' => 'Magento_Backend', - 'depends_on_config' => 'system/config/isEnabled', - 'tooltip' => 'Item tooltip', + 'dependsOnModule' => 'Magento_Backend', + 'dependsOnConfig' => 'system/config/isEnabled', + 'toolTip' => 'Item tooltip', ], ], [ 'parent_id' => '1', - 'module_name' => 'Magento_Module1', + 'module' => 'Magento_Module1', 'sort_index' => '50', - 'depends_on_config' => null, + 'dependsOnConfig' => null, 'id' => '5', 'resource' => null, 'path' => null, 'action' => null, - 'depends_on_module' => null, - 'tooltip' => '', + 'dependsOnModule' => null, + 'toolTip' => '', 'title' => null, 'sub_menu' => [ 'id' => 'item', 'title' => 'Item Title', 'action' => '/system/config', 'resource' => 'Magento_Config::config', - 'depends_on_module' => 'Magento_Backend', - 'depends_on_config' => 'system/config/isEnabled', - 'tooltip' => 'Item tooltip', + 'dependsOnModule' => 'Magento_Backend', + 'dependsOnConfig' => 'system/config/isEnabled', + 'toolTip' => 'Item tooltip', ], 'target' => null ] @@ -82,38 +82,38 @@ 'small set of data' => [ [ 'parent_id' => '1', - 'module_name' => 'Magento_Module1', + 'module' => 'Magento_Module1', 'sort_index' => '50', 'sub_menu' => [ 'id' => 'item', 'title' => 'Item Title', 'action' => '/system/config', 'resource' => 'Magento_Config::config', - 'depends_on_module' => 'Magento_Backend', - 'depends_on_config' => 'system/config/isEnabled', - 'tooltip' => 'Item tooltip', + 'dependsOnModule' => 'Magento_Backend', + 'dependsOnConfig' => 'system/config/isEnabled', + 'toolTip' => 'Item tooltip', ], ], [ 'parent_id' => '1', - 'module_name' => 'Magento_Module1', + 'module' => 'Magento_Module1', 'sort_index' => '50', - 'depends_on_config' => null, + 'dependsOnConfig' => null, 'id' => null, 'resource' => null, 'path' => '', 'action' => null, - 'depends_on_module' => null, - 'tooltip' => '', + 'dependsOnModule' => null, + 'toolTip' => '', 'title' => null, 'sub_menu' => [ 'id' => 'item', 'title' => 'Item Title', 'action' => '/system/config', 'resource' => 'Magento_Config::config', - 'depends_on_module' => 'Magento_Backend', - 'depends_on_config' => 'system/config/isEnabled', - 'tooltip' => 'Item tooltip', + 'dependsOnModule' => 'Magento_Backend', + 'dependsOnConfig' => 'system/config/isEnabled', + 'toolTip' => 'Item tooltip', ], 'target' => null ] diff --git a/app/code/Magento/CmsUrlRewrite/etc/adminhtml/di.xml b/app/code/Magento/CmsUrlRewrite/etc/di.xml similarity index 100% rename from app/code/Magento/CmsUrlRewrite/etc/adminhtml/di.xml rename to app/code/Magento/CmsUrlRewrite/etc/di.xml diff --git a/app/code/Magento/Translation/Block/Js.php b/app/code/Magento/Translation/Block/Js.php index 316c136666cc0..d4d627d19393a 100644 --- a/app/code/Magento/Translation/Block/Js.php +++ b/app/code/Magento/Translation/Block/Js.php @@ -68,4 +68,14 @@ public function getTranslationFilePath() { return $this->fileManager->getTranslationFilePath(); } + + /** + * Gets current version of the translation file. + * + * @return string + */ + public function getTranslationFileVersion() + { + return $this->fileManager->getTranslationFileVersion(); + } } diff --git a/app/code/Magento/Translation/Model/FileManager.php b/app/code/Magento/Translation/Model/FileManager.php index fb989fc6b4518..b4a541f2579c0 100644 --- a/app/code/Magento/Translation/Model/FileManager.php +++ b/app/code/Magento/Translation/Model/FileManager.php @@ -6,6 +6,8 @@ namespace Magento\Translation\Model; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\App\ObjectManager; +use Magento\Translation\Model\Inline\File as TranslationFile; /** * A service for handling Translation config files @@ -32,19 +34,27 @@ class FileManager */ private $driverFile; + /** + * @var TranslationFile + */ + private $translationFile; + /** * @param \Magento\Framework\View\Asset\Repository $assetRepo - * @param \Magento\Framework\App\Filesystem\DirectoryList $directoryList, - * @param \Magento\Framework\Filesystem\Driver\File $driverFile, + * @param \Magento\Framework\App\Filesystem\DirectoryList $directoryList + * @param \Magento\Framework\Filesystem\Driver\File $driverFile + * @param TranslationFile $translationFile */ public function __construct( \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\App\Filesystem\DirectoryList $directoryList, - \Magento\Framework\Filesystem\Driver\File $driverFile + \Magento\Framework\Filesystem\Driver\File $driverFile, + \Magento\Translation\Model\Inline\File $translationFile = null ) { $this->assetRepo = $assetRepo; $this->directoryList = $directoryList; $this->driverFile = $driverFile; + $this->translationFile = $translationFile ?: ObjectManager::getInstance()->get(TranslationFile::class); } /** @@ -110,4 +120,20 @@ public function updateTranslationFileContent($content) } $this->driverFile->filePutContents($this->getTranslationFileFullPath(), $content); } + + /** + * Calculate translation file version hash. + * + * @return string + */ + public function getTranslationFileVersion() + { + $translationFile = $this->getTranslationFileFullPath(); + if (!$this->driverFile->isExists($translationFile)) { + $this->updateTranslationFileContent($this->translationFile->getTranslationFileContent()); + } + + $translationFileHash = sha1_file($translationFile); + return sha1($translationFileHash . $this->getTranslationFilePath()); + } } diff --git a/app/code/Magento/Translation/Model/Inline/File.php b/app/code/Magento/Translation/Model/Inline/File.php new file mode 100644 index 0000000000000..678ceeb1aeec2 --- /dev/null +++ b/app/code/Magento/Translation/Model/Inline/File.php @@ -0,0 +1,60 @@ +translateResource = $translateResource; + $this->localeResolver = $localeResolver; + $this->jsonSerializer = $jsonSerializer; + } + + /** + * Generate translation file content for the current locale. + * + * @return string + */ + public function getTranslationFileContent() + { + $translations = $this->translateResource->getTranslationArray(null, $this->localeResolver->getLocale()); + $translations = $this->jsonSerializer->serialize($translations); + return $translations; + } +} diff --git a/app/code/Magento/Translation/Model/Js/DataProvider.php b/app/code/Magento/Translation/Model/Js/DataProvider.php index 040b3fd211b99..67d594b65b0f5 100644 --- a/app/code/Magento/Translation/Model/Js/DataProvider.php +++ b/app/code/Magento/Translation/Model/Js/DataProvider.php @@ -134,12 +134,13 @@ protected function getPhrases($content) { $phrases = []; foreach ($this->config->getPatterns() as $pattern) { - $result = preg_match_all($pattern, $content, $matches); + $concatenatedContent = preg_replace('~(["\'])\s*?\+\s*?\1~', '', $content); + $result = preg_match_all($pattern, $concatenatedContent, $matches); if ($result) { if (isset($matches[2])) { foreach ($matches[2] as $match) { - $phrases[] = str_replace('\\\'', '\'', $match); + $phrases[] = str_replace(["\'", '\"'], ["'", '"'], $match); } } } diff --git a/app/code/Magento/Translation/Test/Unit/Block/JsTest.php b/app/code/Magento/Translation/Test/Unit/Block/JsTest.php index aa6587c75b6a4..5dc0e6fe5dcaa 100644 --- a/app/code/Magento/Translation/Test/Unit/Block/JsTest.php +++ b/app/code/Magento/Translation/Test/Unit/Block/JsTest.php @@ -65,4 +65,14 @@ public function testGetTranslationFilePath() ->willReturn('frontend/Magento/luma/en_EN'); $this->assertEquals('frontend/Magento/luma/en_EN', $this->model->getTranslationFilePath()); } + + public function testGetTranslationFileVersion() + { + $version = sha1('translationFile'); + + $this->fileManagerMock->expects($this->once()) + ->method('getTranslationFileVersion') + ->willReturn($version); + $this->assertEquals($version, $this->model->getTranslationFileVersion()); + } } diff --git a/app/code/Magento/Translation/Test/Unit/Model/Inline/FileTest.php b/app/code/Magento/Translation/Test/Unit/Model/Inline/FileTest.php new file mode 100644 index 0000000000000..5af8fbdb01f39 --- /dev/null +++ b/app/code/Magento/Translation/Test/Unit/Model/Inline/FileTest.php @@ -0,0 +1,60 @@ +translateResourceMock = $this->getMockBuilder(\Magento\Framework\Translate\ResourceInterface::class) + ->disableOriginalConstructor() + ->getMock(); + $this->localeResolverMock = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class) + ->disableOriginalConstructor() + ->getMock(); + $this->jsonSerializer = new \Magento\Framework\Serialize\Serializer\Json(); + + $this->model = new \Magento\Translation\Model\Inline\File( + $this->translateResourceMock, + $this->localeResolverMock, + $this->jsonSerializer + ); + } + + public function testGetTranslationFileContent() + { + $translations = ['string' => 'translatedString']; + + $this->localeResolverMock->expects($this->atLeastOnce())->method('getLocale')->willReturn('en_US'); + $this->translateResourceMock->expects($this->atLeastOnce())->method('getTranslationArray') + ->willReturn($translations); + + $this->assertEquals( + $this->jsonSerializer->serialize($translations), + $this->model->getTranslationFileContent() + ); + } +} diff --git a/app/code/Magento/Translation/etc/di.xml b/app/code/Magento/Translation/etc/di.xml index 13a170a37ecf2..c10619fbf74ae 100644 --- a/app/code/Magento/Translation/etc/di.xml +++ b/app/code/Magento/Translation/etc/di.xml @@ -65,8 +65,8 @@ - ~\$\.mage\.__\((?s)[^'"]*?(['"])(.+?)\1(?s).*?\)~ - ~\$t\((?s)[^'"]*?(["'])(.+?)\1(?s).*?\)~ + + diff --git a/app/code/Magento/Translation/view/base/templates/translate.phtml b/app/code/Magento/Translation/view/base/templates/translate.phtml index 9e1021022d876..7007cd7fd55a9 100644 --- a/app/code/Magento/Translation/view/base/templates/translate.phtml +++ b/app/code/Magento/Translation/view/base/templates/translate.phtml @@ -26,7 +26,7 @@ $.initNamespaceStorage('mage-translation-file-version'); versionObj = $.localStorage.get('mage-translation-file-version'); - getTranslationFileTimestamp() . $block->getTranslationFilePath()); ?> + getTranslationFileVersion(); ?> if (versionObj.version !== '') { dependencies.push( diff --git a/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php index f30d4a79b4641..c40d1918cca67 100644 --- a/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php @@ -284,6 +284,18 @@ public function testSearch() ); } + /** + * Create page with the same identifier after one was removed. + */ + public function testCreateSamePage() + { + $pageIdentifier = 'page-' . uniqid(); + + $pageId = $this->createPageWithIdentifier($pageIdentifier); + $this->deletePageByIdentifier($pageId); + $this->createPageWithIdentifier($pageIdentifier); + } + /** * @return PageInterface[] */ @@ -316,4 +328,55 @@ private function prepareCmsPages() return $result; } + + /** + * Create page with hard-coded identifier to test with create-delete-create flow. + * @param string $identifier + * @return string + */ + private function createPageWithIdentifier($identifier) + { + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH, + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'Save', + ], + ]; + $requestData = ['page' => + [ + PageInterface::IDENTIFIER => $identifier, + PageInterface::TITLE => 'Page title', + ], + ]; + + $result = $this->_webApiCall($serviceInfo, $requestData); + return $result['id']; + } + + /** + * Remove page with hard-coded-identifier + * @param string $pageId + * @return void + */ + private function deletePageByIdentifier($pageId) + { + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . '/' . $pageId, + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_DELETE, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'DeleteById', + ], + ]; + + $this->_webApiCall($serviceInfo, [PageInterface::PAGE_ID => $pageId]); + } } diff --git a/dev/tests/integration/testsuite/Magento/Backend/Model/MenuTest.php b/dev/tests/integration/testsuite/Magento/Backend/Model/MenuTest.php index a05359cd8dd31..1bebca0236bef 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Model/MenuTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Model/MenuTest.php @@ -96,6 +96,7 @@ public function testSerialize() 'title' => 'Extended System', 'module' => 'Magento_Backend', 'resource' => 'Magento_Backend::system3', + 'dependsOnConfig' => 'dev/test/system', ] ) ); @@ -114,12 +115,13 @@ public function testSerialize() 'Magento_Backend::system3' ); $serializedString = $menu->serialize(); - $expected = '[{"parent_id":null,"module_name":"Magento_Backend","sort_index":null,"depends_on_config":null,' + $expected = '[{"parent_id":null,"module":"Magento_Backend","sort_index":null,' + . '"dependsOnConfig":"dev\/test\/system",' . '"id":"Magento_Backend::system3","resource":"Magento_Backend::system3","path":"","action":null,' - . '"depends_on_module":null,"tooltip":"","title":"Extended System",' - . '"target":null,"sub_menu":[{"parent_id":null,"module_name":"Magento_Backend","sort_index":null,' - . '"depends_on_config":null,"id":"Magento_Backend::system3_acl","resource":"Magento_Backend::system3_acl",' - . '"path":"","action":"admin\/backend\/acl\/index","depends_on_module":null,"tooltip":"","title":"Acl",' + . '"dependsOnModule":null,"toolTip":null,"title":"Extended System",' + . '"target":null,"sub_menu":[{"parent_id":null,"module":"Magento_Backend","sort_index":null,' + . '"dependsOnConfig":null,"id":"Magento_Backend::system3_acl","resource":"Magento_Backend::system3_acl",' + . '"path":"","action":"admin\/backend\/acl\/index","dependsOnModule":null,"toolTip":null,"title":"Acl",' . '"target":null,"sub_menu":null}]}]'; $this->assertEquals($expected, $serializedString); } @@ -129,12 +131,12 @@ public function testSerialize() */ public function testUnserialize() { - $serializedMenu = '[{"parent_id":null,"module_name":"Magento_Backend","sort_index":null,' - . '"depends_on_config":null,"id":"Magento_Backend::system3","resource":"Magento_Backend::system3",' - . '"path":"","action":null,"depends_on_module":null,"tooltip":"","title":"Extended System",' - . '"target":null,"sub_menu":[{"parent_id":null,"module_name":"Magento_Backend","sort_index":null,' - . '"depends_on_config":null,"id":"Magento_Backend::system3_acl","resource":"Magento_Backend::system3_acl",' - . '"path":"","action":"admin\/backend\/acl\/index","depends_on_module":null,"tooltip":"","title":"Acl",' + $serializedMenu = '[{"parent_id":null,"module":"Magento_Backend","sort_index":null,' + . '"dependsOnConfig":"dev\/test","id":"Magento_Backend::system3","resource":"Magento_Backend::system3",' + . '"path":"","action":null,"dependsOnModule":null,"toolTip":null,"title":"Extended System",' + . '"target":null,"sub_menu":[{"parent_id":null,"module":"Magento_Backend","sort_index":null,' + . '"dependsOnConfig":null,"id":"Magento_Backend::system3_acl","resource":"Magento_Backend::system3_acl",' + . '"path":"","action":"admin\/backend\/acl\/index","dependsOnModule":null,"toolTip":null,"title":"Acl",' . '"target":null,"sub_menu":null}]}]'; /** @var Menu $menu */ $menu = $this->objectManager->get(\Magento\Backend\Model\MenuFactory::class)->create(); @@ -142,30 +144,30 @@ public function testUnserialize() $expected = [ [ 'parent_id' => null, - 'module_name' => 'Magento_Backend', + 'module' => 'Magento_Backend', 'sort_index' => null, - 'depends_on_config' => null, + 'dependsOnConfig' => 'dev/test', 'id' => 'Magento_Backend::system3', 'resource' => 'Magento_Backend::system3', 'path' => '', 'action' => null, - 'depends_on_module' => null, - 'tooltip' => '', + 'dependsOnModule' => null, + 'toolTip' => null, 'title' => 'Extended System', 'target' => null, 'sub_menu' => [ [ 'parent_id' => null, - 'module_name' => 'Magento_Backend', + 'module' => 'Magento_Backend', 'sort_index' => null, - 'depends_on_config' => null, + 'dependsOnConfig' => null, 'id' => 'Magento_Backend::system3_acl', 'resource' => 'Magento_Backend::system3_acl', 'path' => '', 'action' => 'admin/backend/acl/index', - 'depends_on_module' => null, - 'tooltip' => '', + 'dependsOnModule' => null, + 'toolTip' => null, 'title' => 'Acl', 'sub_menu' => null, 'target' => null