コード例 #1
0
 /**
  * @covers \Magento\Cms\Model\Wysiwyg\Config::getConfig
  * @param array $data
  * @param boolean $isAuthorizationAllowed
  * @param array $expectedResults
  *
  * @dataProvider getConfigDataProvider
  */
 public function testGetConfig($data, $isAuthorizationAllowed, $expectedResults)
 {
     $wysiwygPluginSettings = ['wysiwygPluginSettings' => 'wysiwyg is here'];
     $pluginSettings = ['pluginSettings' => 'plugins are here'];
     $this->backendUrlMock->expects($this->atLeastOnce())->method('getUrl')->withConsecutive(['cms/wysiwyg/directive'], ['cms/wysiwyg_images/index']);
     $this->assetRepoMock->expects($this->atLeastOnce())->method('getUrl')->withConsecutive(['mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css'], ['mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css']);
     $this->authorizationMock->expects($this->atLeastOnce())->method('isAllowed')->with('Magento_Cms::media_gallery')->willReturn($isAuthorizationAllowed);
     $this->variableConfigMock->expects($this->any())->method('getWysiwygPluginSettings')->willReturn($wysiwygPluginSettings);
     $this->widgetConfigMock->expects($this->any())->method('getPluginSettings')->willReturn($pluginSettings);
     $config = $this->wysiwygConfig->getConfig($data);
     $this->assertInstanceOf('Magento\\Framework\\Object', $config);
     $this->assertEquals($expectedResults[0], $config->getData('someData'));
     $this->assertEquals($expectedResults[1], $config->getData('wysiwygPluginSettings'));
     $this->assertEquals($expectedResults[2], $config->getData('pluginSettings'));
 }
コード例 #2
0
 /**
  * @covers \Magento\Cms\Model\Wysiwyg\Config::getConfig
  * @param array $data
  * @param boolean $isAuthorizationAllowed
  * @param array $expectedResults
  *
  * @dataProvider getConfigDataProvider
  */
 public function testGetConfig($data, $isAuthorizationAllowed, $expectedResults)
 {
     $wysiwygPluginSettings = ['wysiwygPluginSettings' => 'wysiwyg is here'];
     $pluginSettings = ['pluginSettings' => 'plugins are here'];
     $this->backendUrlMock->expects($this->atLeastOnce())->method('getUrl')->withConsecutive(['cms/wysiwyg/directive'], ['cms/wysiwyg_images/index']);
     $this->backendUrlMock->expects($this->once())->method('getBaseUrl')->willReturn('localhost/index.php/');
     $this->assetRepoMock->expects($this->atLeastOnce())->method('getUrl')->withConsecutive(['mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css'], ['mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css']);
     $this->filesystemMock->expects($this->once())->method('getUri')->willReturn('pub/static');
     /** @var \Magento\Framework\View\Asset\ContextInterface|\PHPUnit_Framework_MockObject_MockObject $contextMock */
     $contextMock = $this->getMock(\Magento\Framework\View\Asset\ContextInterface::class);
     $contextMock->expects($this->once())->method('getBaseUrl')->willReturn('localhost/pub/static/');
     $this->assetRepoMock->expects($this->once())->method('getStaticViewFileContext')->willReturn($contextMock);
     $this->authorizationMock->expects($this->atLeastOnce())->method('isAllowed')->with('Magento_Cms::media_gallery')->willReturn($isAuthorizationAllowed);
     $this->variableConfigMock->expects($this->any())->method('getWysiwygPluginSettings')->willReturn($wysiwygPluginSettings);
     $this->widgetConfigMock->expects($this->any())->method('getPluginSettings')->willReturn($pluginSettings);
     $config = $this->wysiwygConfig->getConfig($data);
     $this->assertInstanceOf('Magento\\Framework\\DataObject', $config);
     $this->assertEquals($expectedResults[0], $config->getData('someData'));
     $this->assertEquals($expectedResults[1], $config->getData('wysiwygPluginSettings'));
     $this->assertEquals($expectedResults[2], $config->getData('pluginSettings'));
     $this->assertEquals('localhost/pub/static/', $config->getData('baseStaticUrl'));
     $this->assertEquals('localhost/pub/static/', $config->getData('baseStaticDefaultUrl'));
 }