コード例 #1
0
 /**
  * @test
  * @return void
  * @covers \Magento\Theme\Model\Design\Backend\Exceptions::beforeSave
  * @covers \Magento\Theme\Model\Design\Backend\Exceptions::_composeRegexp
  * @covers \Magento\Theme\Model\Design\Backend\Exceptions::_isRegexp
  * @covers \Magento\Theme\Model\Design\Backend\Exceptions::__construct
  */
 public function testBeforeSave()
 {
     $value = ['__empty' => '', 'test' => ['search' => '1qwe', 'value' => '#val#', 'regexp' => '[a-zA-Z0-9]*']];
     $this->designMock->expects($this->once())->method('setDesignTheme')->with('#val#', Area::AREA_FRONTEND);
     $this->model->setValue($value);
     $this->model->beforeSave();
 }
コード例 #2
0
    public function testGetConfig()
    {
        $this->fileReader->expects($this->any())->method('readAll')->will($this->returnCallback(function ($file) {
            return $file . ' content';
        }));
        $fileOne = $this->getMock('\\Magento\\Framework\\View\\File', [], [], '', false);
        $fileOne->expects($this->once())->method('getFilename')->will($this->returnValue('some/full/relative/path/file_one.js'));
        $fileOne->expects($this->once())->method('getName')->will($this->returnValue('file_one.js'));
        $fileOne->expects($this->once())->method('getModule')->will($this->returnValue('Module_One'));
        $fileTwo = $this->getMock('\\Magento\\Framework\\View\\File', [], [], '', false);
        $fileTwo->expects($this->once())->method('getFilename')->will($this->returnValue('some/full/relative/path/file_two.js'));
        $fileTwo->expects($this->once())->method('getName')->will($this->returnValue('file_two.js'));
        $theme = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Design\\ThemeInterface');
        $this->design->expects($this->once())->method('getDesignTheme')->will($this->returnValue($theme));
        $this->fileSource->expects($this->once())->method('getFiles')->with($theme, Config::CONFIG_FILE_NAME)->will($this->returnValue([$fileOne, $fileTwo]));
        $this->minificationMock->expects($this->atLeastOnce())->method('isEnabled')->with('js')->willReturn(true);
        $expected = <<<expected
(function(require){
(function() {
file_one.js content
require.config(config);
})();
(function() {
file_two.js content
require.config(config);
})();



})(require);
expected;
        $this->minifyAdapterMock->expects($this->once())->method('minify')->with($expected)->willReturnArgument(0);
        $actual = $this->object->getConfig();
        $this->assertEquals($actual, $expected);
    }
コード例 #3
0
ファイル: ConfigTest.php プロジェクト: vasiljok/magento2
    public function testGetConfig()
    {
        $this->baseDir->expects($this->any())->method('getRelativePath')->will($this->returnCallback(function ($path) {
            return 'relative/' . $path;
        }));
        $this->baseDir->expects($this->any())->method('readFile')->will($this->returnCallback(function ($file) {
            return $file . ' content';
        }));
        $fileOne = $this->getMock('\\Magento\\Framework\\View\\File', [], [], '', false);
        $fileOne->expects($this->once())->method('getFilename')->will($this->returnValue('file_one.js'));
        $fileOne->expects($this->once())->method('getModule')->will($this->returnValue('Module_One'));
        $fileTwo = $this->getMock('\\Magento\\Framework\\View\\File', [], [], '', false);
        $fileTwo->expects($this->once())->method('getFilename')->will($this->returnValue('file_two.js'));
        $theme = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Design\\ThemeInterface');
        $this->design->expects($this->once())->method('getDesignTheme')->will($this->returnValue($theme));
        $this->fileSource->expects($this->once())->method('getFiles')->with($theme, Config::CONFIG_FILE_NAME)->will($this->returnValue([$fileOne, $fileTwo]));
        $expected = <<<expected
(function(require){
require.config({"baseUrl":""});
(function() {
relative/file_one.js content
require.config(config);
})();
(function() {
relative/file_two.js content
require.config(config);
})();



})(require);
expected;
        $actual = $this->object->getConfig();
        $this->assertStringMatchesFormat($expected, $actual);
    }
コード例 #4
0
 public function testGetByAreaWithOtherAreaAndNumericThemeId()
 {
     $this->designMock->expects($this->once())->method('getDesignTheme')->will($this->returnValue($this->themeMock));
     $this->designMock->expects($this->once())->method('getArea')->will($this->returnValue('design_area'));
     $this->designMock->expects($this->once())->method('getConfigurationDesignTheme')->will($this->returnValue(12));
     $this->themeMock->expects($this->once())->method('getArea')->will($this->returnValue('theme_area'));
     $this->themeCollectionFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->themeCollectionMock));
     $this->themeCollectionMock->expects($this->once())->method('getItemById')->with(12)->will($this->returnValue($this->themeMock));
     $this->appStateMock->expects($this->once())->method('getAreaCode')->will($this->returnValue('other_area'));
     $this->assertEquals($this->themeMock, $this->model->get());
 }
コード例 #5
0
 public function setUp()
 {
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->viewConfigMock = $this->getMock('\\Magento\\Framework\\View\\Config', ['getMediaAttributes', 'getViewConfig'], [], '', false);
     $this->viewConfigMock->expects($this->atLeastOnce())->method('getViewConfig')->willReturn($this->viewConfigMock);
     $this->themeCustomization = $this->getMock('Magento\\Framework\\View\\Design\\Theme\\Customization', [], [], '', false);
     $themeMock = $this->getMock('Magento\\Theme\\Model\\Theme', ['__wakeup', 'getCustomization'], [], '', false);
     $themeMock->expects($this->any())->method('getCustomization')->will($this->returnValue($this->themeCustomization));
     $this->currentThemeMock = $this->getMock('Magento\\Framework\\View\\DesignInterface');
     $this->currentThemeMock->expects($this->any())->method('getDesignTheme')->will($this->returnValue($themeMock));
     $this->mediaHelperObject = $objectManager->getObject('\\Magento\\ProductVideo\\Helper\\Media', ['configInterface' => $this->viewConfigMock, 'designInterface' => $this->currentThemeMock]);
 }
コード例 #6
0
ファイル: ProductsListTest.php プロジェクト: nja78/magento2
 public function testGetCacheKeyInfo()
 {
     $store = $this->getMockBuilder('\\Magento\\Store\\Model\\Store')->disableOriginalConstructor()->setMethods(['getId'])->getMock();
     $store->expects($this->once())->method('getId')->willReturn(1);
     $this->storeManager->expects($this->once())->method('getStore')->willReturn($store);
     $theme = $this->getMock('\\Magento\\Framework\\View\\Design\\ThemeInterface');
     $theme->expects($this->once())->method('getId')->willReturn('blank');
     $this->design->expects($this->once())->method('getDesignTheme')->willReturn($theme);
     $this->httpContext->expects($this->once())->method('getValue')->willReturn('context_group');
     $this->productsList->setData('conditions', 'some_serialized_conditions');
     $this->request->expects($this->once())->method('getParam')->with('np')->willReturn(1);
     $cacheKey = ['CATALOG_PRODUCTS_LIST_WIDGET', 1, 'blank', 'context_group', 1, 5, 'some_serialized_conditions'];
     $this->assertEquals($cacheKey, $this->productsList->getCacheKeyInfo());
 }
コード例 #7
0
 public function testGetCacheKeyInfo()
 {
     $store = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $store->expects($this->atLeastOnce())->method('getId')->willReturn(55);
     $store->expects($this->atLeastOnce())->method('getRootCategoryId')->willReturn(60);
     $this->storeManager->expects($this->atLeastOnce())->method('getStore')->willReturn($store);
     $theme = $this->getMock('\\Magento\\Framework\\View\\Design\\ThemeInterface');
     $theme->expects($this->atLeastOnce())->method('getId')->willReturn(65);
     $this->design->expects($this->atLeastOnce())->method('getDesignTheme')->willReturn($theme);
     $this->httpContext->expects($this->atLeastOnce())->method('getValue')->with(\Magento\Customer\Model\Context::CONTEXT_GROUP)->willReturn(70);
     $this->block->setTemplate('block_template');
     $this->block->setNameInLayout('block_name');
     $expectedResult = ['CATALOG_NAVIGATION', 55, 65, 70, 'template' => 'block_template', 'name' => 'block_name', 60, 'category_path' => 60, 'short_cache_id' => 'c3de6d1160d1e7730b04d6cad409a2b4'];
     $this->assertEquals($expectedResult, $this->block->getCacheKeyInfo());
 }
コード例 #8
0
ファイル: EmulationTest.php プロジェクト: tingyeeh/magento2
 public function testStop()
 {
     // Test data
     $initArea = 'initial area';
     $initTheme = 'initial design theme';
     $initLocale = 'initial locale code';
     $initialStore = 1;
     $initTranslateInline = false;
     $this->inlineTranslationMock->expects($this->once())->method('isEnabled')->willReturn($initTranslateInline);
     $this->viewDesignMock->expects($this->once())->method('getArea')->willReturn($initArea);
     $this->viewDesignMock->expects($this->once())->method('getDesignTheme')->willReturn($initTheme);
     $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
     $this->storeMock->expects($this->once())->method('getStoreId')->willReturn($initialStore);
     $this->localeResolverMock->expects($this->once())->method('getLocale')->willReturn($initLocale);
     $this->model->storeCurrentEnvironmentInfo();
     // Expectations
     $this->inlineTranslationMock->expects($this->once())->method('resume')->with($initTranslateInline);
     $this->viewDesignMock->expects($this->once())->method('setDesignTheme')->with($initTheme, $initArea);
     $this->storeManagerMock->expects($this->once())->method('setCurrentStore')->with($initialStore);
     $this->localeResolverMock->expects($this->once())->method('setLocale')->with($initLocale);
     $this->translateMock->expects($this->once())->method('setLocale')->with($initLocale);
     $this->translateMock->expects($this->once())->method('loadData')->with($initArea);
     // Test
     $this->model->stopEnvironmentEmulation();
 }
コード例 #9
0
 private function mockDesign()
 {
     $params = array('area' => 'area', 'themeModel' => $this->theme, 'locale' => 'locale');
     $this->design->expects($this->atLeastOnce())->method('getDesignParams')->will($this->returnValue($params));
     $this->design->expects($this->any())->method('getConfigurationDesignTheme')->with('area')->will($this->returnValue($this->theme));
     $this->design->expects($this->any())->method('getThemePath')->with($this->theme)->will($this->returnValue('theme'));
     $this->themeList->expects($this->any())->method('getThemeByFullPath')->will($this->returnValue($this->theme));
 }
コード例 #10
0
 /**
  * Declare calls expectation for setConfig() method
  */
 protected function expectsSetConfig($themeId, $localeCode = 'en_US')
 {
     $this->locale->expects($this->any())->method('getLocaleCode')->will($this->returnValue($localeCode));
     $scope = new \Magento\Framework\Object(['code' => 'frontendCode', 'id' => 1]);
     $scopeAdmin = new \Magento\Framework\Object(['code' => 'adminCode', 'id' => 0]);
     $this->scopeResolver->expects($this->any())->method('getScope')->will($this->returnValueMap([[null, $scope], ['admin', $scopeAdmin]]));
     $designTheme = new \Magento\Framework\Object(['id' => $themeId]);
     $this->viewDesign->expects($this->any())->method('getDesignTheme')->will($this->returnValue($designTheme));
 }
コード例 #11
0
 /**
  * @return void
  */
 public function testGetUrl()
 {
     $themeMock = $this->getMock('Magento\\Framework\\View\\Design\\ThemeInterface', [], [], '', false);
     $this->designMock->expects($this->any())->method('getDesignParams')->willReturn(['themeModel' => $themeMock, 'area' => 'area', 'locale' => 'locale']);
     $assetMock = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\File')->disableOriginalConstructor()->getMock();
     $assetMock->expects($this->any())->method('getUrl')->willReturn('some url');
     $this->fileFactoryMock->expects($this->exactly(2))->method('create')->with(['source' => $this->sourceMock, 'context' => '', 'filePath' => 'test/file.js', 'module' => '', 'contentType' => ''])->willReturn($assetMock);
     $this->assertEquals('some url', $this->repository->getUrl('test/file.js'));
     $this->assertEquals('some url', $this->repository->getUrlWithParams('test/file.js', []));
 }
コード例 #12
0
 /**
  * @covers \Magento\Cms\Helper\Page::renderPageExtended
  * @param integer|null $pageId
  * @param integer|null $internalPageId
  * @param integer $pageLoadResultIndex
  * @param string $customPageLayout
  * @param string $handle
  * @param string $customLayoutUpdateXml
  * @param string $layoutUpdate
  * @param boolean $expectedResult
  *
  * @dataProvider renderPageExtendedDataProvider
  *
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testRenderPageExtended($pageId, $internalPageId, $pageLoadResultIndex, $customPageLayout, $handle, $customLayoutUpdateXml, $layoutUpdate, $expectedResult)
 {
     $storeId = 321;
     $customThemeFrom = 'customThemeFrom';
     $customThemeTo = 'customThemeTo';
     $isScopeDateInInterval = true;
     $customTheme = 'customTheme';
     $pageLayout = 'pageLayout';
     $pageIdentifier = 111;
     $layoutUpdateXml = 'layoutUpdateXml';
     $contentHeading = 'contentHeading';
     $escapedContentHeading = 'escapedContentHeading';
     $defaultGroup = 'defaultGroup';
     $pageLoadResultCollection = [null, $this->pageMock];
     $this->pageMock->expects($this->any())->method('getId')->willReturn($internalPageId);
     $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
     $this->storeMock->expects($this->any())->method('getId')->willReturn($storeId);
     $this->pageMock->expects($this->any())->method('setStoreId')->with($storeId)->willReturnSelf();
     $this->pageMock->expects($this->any())->method('load')->with($pageId)->willReturn($pageLoadResultCollection[$pageLoadResultIndex]);
     $this->pageMock->expects($this->any())->method('getCustomThemeFrom')->willReturn($customThemeFrom);
     $this->pageMock->expects($this->any())->method('getCustomThemeTo')->willReturn($customThemeTo);
     $this->localeDateMock->expects($this->any())->method('isScopeDateInInterval')->with(null, $customThemeFrom, $customThemeTo)->willReturn($isScopeDateInInterval);
     $this->pageMock->expects($this->any())->method('getCustomTheme')->willReturn($customTheme);
     $this->designMock->expects($this->any())->method('setDesignTheme')->with($customTheme)->willReturnSelf();
     $this->pageMock->expects($this->any())->method('getPageLayout')->willReturn($pageLayout);
     $this->pageMock->expects($this->any())->method('getCustomPageLayout')->willReturn($customPageLayout);
     $this->resultPageMock->expects($this->any())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->pageConfigMock->expects($this->any())->method('setPageLayout')->with($handle)->willReturnSelf();
     $this->viewMock->expects($this->any())->method('getPage')->willReturn($this->resultPageMock);
     $this->resultPageMock->expects($this->any())->method('initLayout')->willReturnSelf();
     $this->resultPageMock->expects($this->any())->method('getLayout')->willReturn($this->layoutMock);
     $this->layoutMock->expects($this->any())->method('getUpdate')->willReturn($this->layoutProcessorMock);
     $this->layoutProcessorMock->expects($this->any())->method('addHandle')->with('cms_page_view')->willReturnSelf();
     $this->pageMock->expects($this->any())->method('getIdentifier')->willReturn($pageIdentifier);
     $this->viewMock->expects($this->any())->method('addPageLayoutHandles')->with(['id' => $pageIdentifier])->willReturn(true);
     $this->eventManagerMock->expects($this->any())->method('dispatch')->with('cms_page_render', ['page' => $this->pageMock, 'controller_action' => $this->actionMock]);
     $this->viewMock->expects($this->any())->method('loadLayoutUpdates')->willReturnSelf();
     $this->pageMock->expects($this->any())->method('getCustomLayoutUpdateXml')->willReturn($customLayoutUpdateXml);
     $this->pageMock->expects($this->any())->method('getLayoutUpdateXml')->willReturn($layoutUpdateXml);
     $this->layoutProcessorMock->expects($this->any())->method('addUpdate')->with($layoutUpdate)->willReturnSelf();
     $this->viewMock->expects($this->any())->method('generateLayoutXml')->willReturnSelf();
     $this->viewMock->expects($this->any())->method('generateLayoutBlocks')->willReturnSelf();
     $this->layoutMock->expects($this->any())->method('getBlock')->with('page_content_heading')->willReturn($this->blockMock);
     $this->pageMock->expects($this->any())->method('getContentHeading')->willReturn($contentHeading);
     $this->escaperMock->expects($this->any())->method('escapeHtml')->with($contentHeading)->willReturn($escapedContentHeading);
     $this->blockMock->expects($this->any())->method('setContentHeading')->with($escapedContentHeading)->willReturnSelf();
     $this->layoutMock->expects($this->any())->method('getMessagesBlock')->willReturn($this->messagesBlockMock);
     $this->messageManagerMock->expects($this->any())->method('getDefaultGroup')->willReturn($defaultGroup);
     $this->messagesBlockMock->expects($this->any())->method('addStorageType')->with($defaultGroup);
     $this->messageManagerMock->expects($this->any())->method('getMessages')->with(true)->willReturn($this->messageCollectionMock);
     $this->messagesBlockMock->expects($this->any())->method('addMessages')->with($this->messageCollectionMock)->willReturnSelf();
     $this->viewMock->expects($this->any())->method('renderLayout')->willReturnSelf();
     $this->assertEquals($expectedResult, $this->object->renderPageExtended($this->actionMock, $pageId));
 }
コード例 #13
0
 protected function setUp()
 {
     $this->_viewFileSystem = $this->getMock('Magento\\Framework\\View\\FileSystem', array('getLocaleFileName', 'getDesignTheme'), array(), '', false);
     $this->_viewFileSystem->expects($this->any())->method('getLocaleFileName')->will($this->returnValue(dirname(__DIR__) . '/Core/Model/_files/design/frontend/test_default/i18n/en_US.csv'));
     $theme = $this->getMock('\\Magento\\Framework\\View\\Design\\ThemeInterface', array());
     $theme->expects($this->any())->method('getId')->will($this->returnValue(10));
     $this->_viewFileSystem->expects($this->any())->method('getDesignTheme')->will($this->returnValue($theme));
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $objectManager->addSharedInstance($this->_viewFileSystem, 'Magento\\Framework\\View\\FileSystem');
     /** @var $moduleReader \Magento\Framework\Module\Dir\Reader */
     $moduleReader = $objectManager->get('Magento\\Framework\\Module\\Dir\\Reader');
     $moduleReader->setModuleDir('Magento_Core', 'i18n', dirname(__DIR__) . '/Core/Model/_files/Magento/Core/i18n');
     $moduleReader->setModuleDir('Magento_Catalog', 'i18n', dirname(__DIR__) . '/Core/Model/_files/Magento/Catalog/i18n');
     /** @var \Magento\Core\Model\View\Design _designModel */
     $this->_designModel = $this->getMock('Magento\\Core\\Model\\View\\Design', array('getDesignTheme'), array($objectManager->get('Magento\\Framework\\StoreManagerInterface'), $objectManager->get('Magento\\Framework\\View\\Design\\Theme\\FlyweightFactory'), $objectManager->get('Magento\\Framework\\App\\Config\\ScopeConfigInterface'), $objectManager->get('Magento\\Core\\Model\\ThemeFactory'), $objectManager->get('Magento\\Framework\\Locale\\ResolverInterface'), $objectManager->get('Magento\\Framework\\App\\State'), array('frontend' => 'test_default')));
     $this->_designModel->expects($this->any())->method('getDesignTheme')->will($this->returnValue($theme));
     $objectManager->addSharedInstance($this->_designModel, 'Magento\\Core\\Model\\View\\Design\\Proxy');
     $this->_model = $objectManager->create('Magento\\Framework\\Translate');
     $objectManager->addSharedInstance($this->_model, 'Magento\\Framework\\Translate');
     $objectManager->removeSharedInstance('Magento\\Framework\\Phrase\\Renderer\\Composite');
     $objectManager->removeSharedInstance('Magento\\Framework\\Phrase\\Renderer\\Translate');
     \Magento\Framework\Phrase::setRenderer($objectManager->get('Magento\\Framework\\Phrase\\RendererInterface'));
     $this->_model->loadData(\Magento\Framework\App\Area::AREA_FRONTEND);
 }
コード例 #14
0
 /**
  * @covers \Magento\Cms\Helper\Page::prepareResultPage
  * @param integer|null $pageId
  * @param integer|null $internalPageId
  * @param integer $pageLoadResultIndex
  * @param string $customPageLayout
  * @param string $handle
  * @param string $customLayoutUpdateXml
  * @param string $layoutUpdate
  * @param boolean $expectedResult
  *
  * @dataProvider renderPageExtendedDataProvider
  *
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testPrepareResultPage($pageId, $internalPageId, $pageLoadResultIndex, $customPageLayout, $handle, $customLayoutUpdateXml, $layoutUpdate, $expectedResult)
 {
     $storeId = 321;
     $customThemeFrom = 'customThemeFrom';
     $customThemeTo = 'customThemeTo';
     $isScopeDateInInterval = true;
     $customTheme = 'customTheme';
     $pageLayout = 'pageLayout';
     $pageIdentifier = 111;
     $layoutUpdateXml = 'layoutUpdateXml';
     $contentHeading = 'contentHeading';
     $escapedContentHeading = 'escapedContentHeading';
     $pageLoadResultCollection = [null, $this->pageMock];
     $this->pageMock->expects($this->any())->method('getId')->willReturn($internalPageId);
     $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
     $this->storeMock->expects($this->any())->method('getId')->willReturn($storeId);
     $this->pageMock->expects($this->any())->method('setStoreId')->with($storeId)->willReturnSelf();
     $this->pageMock->expects($this->any())->method('load')->with($pageId)->willReturn($pageLoadResultCollection[$pageLoadResultIndex]);
     $this->pageMock->expects($this->any())->method('getCustomThemeFrom')->willReturn($customThemeFrom);
     $this->pageMock->expects($this->any())->method('getCustomThemeTo')->willReturn($customThemeTo);
     $this->localeDateMock->expects($this->any())->method('isScopeDateInInterval')->with(null, $customThemeFrom, $customThemeTo)->willReturn($isScopeDateInInterval);
     $this->pageMock->expects($this->any())->method('getCustomTheme')->willReturn($customTheme);
     $this->designMock->expects($this->any())->method('setDesignTheme')->with($customTheme)->willReturnSelf();
     $this->pageMock->expects($this->any())->method('getPageLayout')->willReturn($pageLayout);
     $this->pageMock->expects($this->any())->method('getCustomPageLayout')->willReturn($customPageLayout);
     $this->resultPageFactory->expects($this->any())->method('create')->will($this->returnValue($this->resultPageMock));
     $this->resultPageMock->expects($this->any())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->pageConfigMock->expects($this->any())->method('setPageLayout')->with($handle)->willReturnSelf();
     $this->resultPageMock->expects($this->any())->method('initLayout')->willReturnSelf();
     $this->resultPageMock->expects($this->any())->method('getLayout')->willReturn($this->layoutMock);
     $this->layoutMock->expects($this->any())->method('getUpdate')->willReturn($this->layoutProcessorMock);
     $this->layoutProcessorMock->expects($this->any())->method('addHandle')->with('cms_page_view')->willReturnSelf();
     $this->pageMock->expects($this->any())->method('getIdentifier')->willReturn($pageIdentifier);
     $this->eventManagerMock->expects($this->any())->method('dispatch')->with('cms_page_render', ['page' => $this->pageMock, 'controller_action' => $this->actionMock]);
     $this->pageMock->expects($this->any())->method('getCustomLayoutUpdateXml')->willReturn($customLayoutUpdateXml);
     $this->pageMock->expects($this->any())->method('getLayoutUpdateXml')->willReturn($layoutUpdateXml);
     $this->layoutProcessorMock->expects($this->any())->method('addUpdate')->with($layoutUpdate)->willReturnSelf();
     $this->layoutMock->expects($this->any())->method('getBlock')->with('page_content_heading')->willReturn($this->blockMock);
     $this->pageMock->expects($this->any())->method('getContentHeading')->willReturn($contentHeading);
     $this->escaperMock->expects($this->any())->method('escapeHtml')->with($contentHeading)->willReturn($escapedContentHeading);
     $this->blockMock->expects($this->any())->method('setContentHeading')->with($escapedContentHeading)->willReturnSelf();
     if ($expectedResult) {
         $expectedResult = $this->resultPageMock;
     }
     $this->assertSame($expectedResult, $this->object->prepareResultPage($this->actionMock, $pageId));
 }
コード例 #15
0
ファイル: ThemeTest.php プロジェクト: nja78/magento2
 /**
  * @test
  * @return void
  * @covers \Magento\Theme\Model\Design\Backend\Theme::beforeSave
  * @covers \Magento\Theme\Model\Design\Backend\Theme::__construct
  */
 public function testBeforeSave()
 {
     $this->design->expects($this->once())->method('setDesignTheme')->with('some_value', Area::AREA_FRONTEND);
     $this->model->setValue('some_value');
     $this->assertInstanceOf(get_class($this->model), $this->model->beforeSave());
 }
コード例 #16
0
 /**
  * @covers \Magento\Theme\Model\Config\Customization::isThemeAssignedToStore
  */
 public function testIsThemeAssignedToConcreteStore()
 {
     $this->designPackage->expects($this->once())->method('getConfigurationDesignTheme')->willReturn($this->getAssignedTheme()->getId());
     $themeUnassigned = $this->model->isThemeAssignedToStore($this->getUnassignedTheme(), $this->getStore());
     $this->assertEquals(false, $themeUnassigned);
 }