Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
ConfigTest Class Reference
Inheritance diagram for ConfigTest:

Public Member Functions

 getConfigDataProvider ()
 
 testGetSkinImagePlaceholderPath ()
 
 testIsEnabled ($wysiwygState, $expectedResult)
 
 isEnabledDataProvider ()
 
 testIsHidden ($status, $expectedResult)
 
 isHiddenDataProvider ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $wysiwygConfig
 
 $backendUrlMock
 
 $assetRepoMock
 
 $authorizationMock
 
 $variableConfigMock
 
 $widgetConfigMock
 
 $scopeConfigMock
 
 $storeManagerMock
 
 $storeMock
 
 $assetFileMock
 
 $filesystemMock
 
 $windowSize = []
 

Detailed Description

@covers \Magento\Cms\Model\Wysiwyg\Config @SuppressWarnings(PHPMD.CouplingBetweenObjects)

Definition at line 12 of file ConfigTest.php.

Member Function Documentation

◆ getConfigDataProvider()

getConfigDataProvider ( )
Returns
array

Definition at line 205 of file ConfigTest.php.

206  {
207  return [
208  'add_variables IS FALSE, add_widgets IS FALSE, isAuthorizationAllowed IS FALSE' => [
209  'data' => [
210  'add_variables' => false,
211  'add_widgets' => false,
212  ],
213  'isAuthorizationAllowed' => false,
214  'expectedResults' => [null, null, null],
215  ],
216  'add_variables IS TRUE, add_widgets IS TRUE, isAuthorizationAllowed IS TRUE' => [
217  'data' => [
218  'someData' => 'important data',
219  'add_variables' => true,
220  'add_widgets' => true,
221  ],
222  'isAuthorizationAllowed' => true,
223  'expectedResults' => ['important data', 'wysiwyg is here', 'plugins are here'],
224  ]
225  ];
226  }

◆ isEnabledDataProvider()

isEnabledDataProvider ( )
Returns
array

Definition at line 277 of file ConfigTest.php.

278  {
279  return [
280  ['wysiwygState' => 'enabled', 'expectedResult' => true],
281  ['wysiwygState' => 'hidden', 'expectedResult' => true],
282  ['wysiwygState' => 'masked', 'expectedResult' => false]
283  ];
284  }

◆ isHiddenDataProvider()

isHiddenDataProvider ( )
Returns
array

Definition at line 306 of file ConfigTest.php.

307  {
308  return [
309  ['status' => 'hidden', 'expectedResult' => true],
310  ['status' => 'enabled', 'expectedResult' => false],
311  ['status' => 'masked', 'expectedResult' => false]
312  ];
313  }

◆ setUp()

setUp ( )
protected

Definition at line 79 of file ConfigTest.php.

80  {
81  $this->filesystemMock = $this->createMock(\Magento\Framework\Filesystem::class);
82  $this->backendUrlMock = $this->getMockBuilder(\Magento\Backend\Model\UrlInterface::class)
83  ->disableOriginalConstructor()
84  ->getMock();
85  $this->assetRepoMock = $this->getMockBuilder(\Magento\Framework\View\Asset\Repository::class)
86  ->disableOriginalConstructor()
87  ->getMock();
88  $this->authorizationMock = $this->getMockBuilder(\Magento\Framework\AuthorizationInterface::class)
89  ->disableOriginalConstructor()
90  ->getMock();
91  $this->variableConfigMock = $this->getMockBuilder(\Magento\Variable\Model\Variable\Config::class)
92  ->disableOriginalConstructor()
93  ->getMock();
94  $this->widgetConfigMock = $this->getMockBuilder(\Magento\Widget\Model\Widget\Config::class)
95  ->disableOriginalConstructor()
96  ->getMock();
97  $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
98  ->disableOriginalConstructor()
99  ->getMock();
100  $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
101  ->disableOriginalConstructor()
102  ->getMock();
103  $this->storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class)
104  ->disableOriginalConstructor()
105  ->getMock();
106  $this->assetFileMock = $this->getMockBuilder(\Magento\Framework\View\Asset\File::class)
107  ->disableOriginalConstructor()
108  ->getMock();
109  $this->windowSize = [
110  'width' => 1200,
111  'height' => 800,
112  ];
113  $defaultConfigProvider = new \Magento\Cms\Model\WysiwygDefaultConfig();
114  $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
115  $configProviderFactory = $this->getMockBuilder(\Magento\Cms\Model\Wysiwyg\ConfigProviderFactory::class)
116  ->disableOriginalConstructor()
117  ->getMock();
118  $configProviderFactory->expects($this->any())->method('create')->willReturn($defaultConfigProvider);
119  $this->configProvider = $this->getMockBuilder(\Magento\Cms\Model\Wysiwyg\CompositeConfigProvider::class)
120  ->enableOriginalConstructor()
121  ->setConstructorArgs(
122  [
123  'activeEditor' => $this->getMockBuilder(\Magento\Ui\Block\Wysiwyg\ActiveEditor::class)
124  ->disableOriginalConstructor()->getMock(),
125  'configProviderFactory' => $configProviderFactory,
126  'variablePluginConfigProvider' => ['default' => \Magento\Cms\Model\WysiwygDefaultConfig::class],
127  'widgetPluginConfigProvider' => ['default' => \Magento\Cms\Model\WysiwygDefaultConfig::class],
128  'wysiwygConfigPostProcessor' => ['default' => \Magento\Cms\Model\WysiwygDefaultConfig::class],
129  'galleryConfigProvider' => ['default' => \Magento\Cms\Model\WysiwygDefaultConfig::class],
130  ]
131  )
132  ->setMethods(['processVariableConfig', 'processWidgetConfig'])
133  ->getMock();
134 
135  $this->wysiwygConfig = $objectManager->getObject(
136  \Magento\Cms\Model\Wysiwyg\Config::class,
137  [
138  'backendUrl' => $this->backendUrlMock,
139  'assetRepo' => $this->assetRepoMock,
140  'authorization' => $this->authorizationMock,
141  'variableConfig' => $this->variableConfigMock,
142  'widgetConfig' => $this->widgetConfigMock,
143  'scopeConfig' => $this->scopeConfigMock,
144  'windowSize' => $this->windowSize,
145  'storeManager' => $this->storeManagerMock,
146  'filesystem' => $this->filesystemMock,
147  'configProvider' => $this->configProvider
148  ]
149  );
150  }
$objectManager
Definition: bootstrap.php:17

◆ testGetSkinImagePlaceholderPath()

testGetSkinImagePlaceholderPath ( )

@covers \Magento\Cms\Model\Wysiwyg\Config::getSkinImagePlaceholderPath

Definition at line 231 of file ConfigTest.php.

232  {
233  $staticPath = 'pub/static';
234  $placeholderPath = 'adminhtml/Magento/backend/en_US/Magento_Cms/images/wysiwyg_skin_image.png';
235  $expectedResult = 'pub/static/adminhtml/Magento/backend/en_US/Magento_Cms/images/wysiwyg_skin_image.png';
236 
237  $this->storeManagerMock->expects($this->any())
238  ->method('getStore')
239  ->willReturn($this->storeMock);
240  $this->storeMock->expects($this->any())
241  ->method('getBaseStaticDir')
242  ->willReturn($staticPath);
243  $this->assetRepoMock->expects($this->any())
244  ->method('createAsset')
245  ->with(\Magento\Cms\Model\Wysiwyg\Config::WYSIWYG_SKIN_IMAGE_PLACEHOLDER_ID)
246  ->willReturn($this->assetFileMock);
247  $this->assetFileMock->expects($this->once())
248  ->method('getPath')
249  ->willReturn($placeholderPath);
250 
251  $this->assertEquals($expectedResult, $this->wysiwygConfig->getSkinImagePlaceholderPath());
252  }

◆ testIsEnabled()

testIsEnabled (   $wysiwygState,
  $expectedResult 
)

@covers \Magento\Cms\Model\Wysiwyg\Config::isEnabled

Parameters
string$wysiwygState
boolean$expectedResult@dataProvider isEnabledDataProvider

Definition at line 261 of file ConfigTest.php.

262  {
263  $storeId = 1;
264  $this->wysiwygConfig->setStoreId($storeId);
265 
266  $this->scopeConfigMock->expects($this->atLeastOnce())
267  ->method('getValue')
268  ->with('cms/wysiwyg/enabled', 'store', $storeId)
269  ->willReturn($wysiwygState);
270 
271  $this->assertEquals($expectedResult, $this->wysiwygConfig->isEnabled());
272  }

◆ testIsHidden()

testIsHidden (   $status,
  $expectedResult 
)

@covers \Magento\Cms\Model\Wysiwyg\Config::isHidden

Parameters
string$status
boolean$expectedResult@dataProvider isHiddenDataProvider

Definition at line 293 of file ConfigTest.php.

294  {
295  $this->scopeConfigMock->expects($this->atLeastOnce())
296  ->method('getValue')
297  ->with('cms/wysiwyg/enabled', 'store')
298  ->willReturn($status);
299 
300  $this->assertEquals($expectedResult, $this->wysiwygConfig->isHidden());
301  }
$status
Definition: order_status.php:8

Field Documentation

◆ $assetFileMock

$assetFileMock
protected

Definition at line 62 of file ConfigTest.php.

◆ $assetRepoMock

$assetRepoMock
protected

Definition at line 27 of file ConfigTest.php.

◆ $authorizationMock

$authorizationMock
protected

Definition at line 32 of file ConfigTest.php.

◆ $backendUrlMock

$backendUrlMock
protected

Definition at line 22 of file ConfigTest.php.

◆ $filesystemMock

$filesystemMock
protected

Definition at line 67 of file ConfigTest.php.

◆ $scopeConfigMock

$scopeConfigMock
protected

Definition at line 47 of file ConfigTest.php.

◆ $storeManagerMock

$storeManagerMock
protected

Definition at line 52 of file ConfigTest.php.

◆ $storeMock

$storeMock
protected

Definition at line 57 of file ConfigTest.php.

◆ $variableConfigMock

$variableConfigMock
protected

Definition at line 37 of file ConfigTest.php.

◆ $widgetConfigMock

$widgetConfigMock
protected

Definition at line 42 of file ConfigTest.php.

◆ $windowSize

$windowSize = []
protected

Definition at line 77 of file ConfigTest.php.

◆ $wysiwygConfig

$wysiwygConfig
protected

Definition at line 17 of file ConfigTest.php.


The documentation for this class was generated from the following file: