diff --git a/app/code/Magento/Backend/Test/Unit/Model/MenuTest.php b/app/code/Magento/Backend/Test/Unit/Model/MenuTest.php index 294ff9b41dce6f959591ff9bc013683f62bbfe3c..12968df9f340f888a2999d516a1304510b181316 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/MenuTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/MenuTest.php @@ -368,14 +368,9 @@ class MenuTest extends \PHPUnit_Framework_TestCase ->method('unserialize') ->willReturn([['unserializedData']]); $menuItemFactoryMock = $this->getMock(Factory::class, [], [], '', false); - $menuItemMock = $this->getMock(Item::class, [], [], '', false); $menuItemFactoryMock->expects($this->once()) ->method('create') - ->willReturn($menuItemMock); - $menuItemMock->expects($this->once()) - ->method('populateFromArray') - ->with(['unserializedData']) - ->willReturn($this); + ->with(['unserializedData']); $menu = $this->objectManagerHelper->getObject( \Magento\Backend\Model\Menu::class, [ diff --git a/dev/tests/integration/testsuite/Magento/Backend/Model/MenuTest.php b/dev/tests/integration/testsuite/Magento/Backend/Model/MenuTest.php index 7bdb208475ee133dd054f7d054ca33e6c88b3fff..6c51e061f9db7af18ebf5629742c4edeb03771ca 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Model/MenuTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Model/MenuTest.php @@ -78,7 +78,10 @@ class MenuTest extends \PHPUnit_Framework_TestCase $menu->move('Magento_Catalog::catalog_products', 'Magento_Backend::system2'); } - public function testSerializeUnserialize() + /** + * @magentoAppIsolation enabled + */ + public function testSerialize() { /** @var Menu $menu */ $menu = $this->objectManager->get(\Magento\Backend\Model\MenuFactory::class)->create(); @@ -111,9 +114,63 @@ class MenuTest extends \PHPUnit_Framework_TestCase 'Magento_Backend::system3' ); $serializedString = $menu->serialize(); - /** @var Menu $unserializedMenu */ - $unserializedMenu = $this->objectManager->get(\Magento\Backend\Model\MenuFactory::class)->create(); - $unserializedMenu->unserialize($serializedString); - $this->assertEquals($menu, $unserializedMenu); + $expected = '[{"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",' + . '"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",' + . '"sub_menu":null}]}]'; + $this->assertEquals($expected, $serializedString); + } + + /** + * @magentoAppIsolation enabled + */ + 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",' + . '"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",' + . '"sub_menu":null}]}]'; + /** @var Menu $menu */ + $menu = $this->objectManager->get(\Magento\Backend\Model\MenuFactory::class)->create(); + $menu->unserialize($serializedMenu); + $expected = [ + [ + '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', + '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', + 'sub_menu' => null, + ], + ], + ], + ]; + $this->assertEquals($expected, $menu->toArray()); } }