7
7
8
8
/**
9
9
* @covers \Magento\Cms\Model\Wysiwyg\Config
10
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
10
11
*/
11
12
class ConfigTest extends \PHPUnit_Framework_TestCase
12
13
{
@@ -60,13 +61,19 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
60
61
*/
61
62
protected $ assetFileMock ;
62
63
64
+ /**
65
+ * @var \Magento\Framework\Filesystem|\PHPUnit_Framework_MockObject_MockObject
66
+ */
67
+ protected $ filesystemMock ;
68
+
63
69
/**
64
70
* @var array
65
71
*/
66
72
protected $ windowSize = [];
67
73
68
74
protected function setUp ()
69
75
{
76
+ $ this ->filesystemMock = $ this ->getMock (\Magento \Framework \Filesystem::class, [], [], '' , false );
70
77
$ this ->backendUrlMock = $ this ->getMockBuilder ('Magento\Backend\Model\UrlInterface ' )
71
78
->disableOriginalConstructor ()
72
79
->getMock ();
@@ -110,7 +117,8 @@ protected function setUp()
110
117
'widgetConfig ' => $ this ->widgetConfigMock ,
111
118
'scopeConfig ' => $ this ->scopeConfigMock ,
112
119
'windowSize ' => $ this ->windowSize ,
113
- 'storeManager ' => $ this ->storeManagerMock
120
+ 'storeManager ' => $ this ->storeManagerMock ,
121
+ 'filesystem ' => $ this ->filesystemMock ,
114
122
]
115
123
);
116
124
}
@@ -139,12 +147,26 @@ public function testGetConfig($data, $isAuthorizationAllowed, $expectedResults)
139
147
['cms/wysiwyg/directive ' ],
140
148
['cms/wysiwyg_images/index ' ]
141
149
);
150
+ $ this ->backendUrlMock ->expects ($ this ->once ())
151
+ ->method ('getBaseUrl ' )
152
+ ->willReturn ('localhost/index.php/ ' );
142
153
$ this ->assetRepoMock ->expects ($ this ->atLeastOnce ())
143
154
->method ('getUrl ' )
144
155
->withConsecutive (
145
156
['mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css ' ],
146
157
['mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css ' ]
147
158
);
159
+ $ this ->filesystemMock ->expects ($ this ->once ())
160
+ ->method ('getUri ' )
161
+ ->willReturn ('pub/static ' );
162
+ /** @var \Magento\Framework\View\Asset\ContextInterface|\PHPUnit_Framework_MockObject_MockObject $contextMock */
163
+ $ contextMock = $ this ->getMock (\Magento \Framework \View \Asset \ContextInterface::class);
164
+ $ contextMock ->expects ($ this ->once ())
165
+ ->method ('getBaseUrl ' )
166
+ ->willReturn ('localhost/pub/static/ ' );
167
+ $ this ->assetRepoMock ->expects ($ this ->once ())
168
+ ->method ('getStaticViewFileContext ' )
169
+ ->willReturn ($ contextMock );
148
170
$ this ->authorizationMock ->expects ($ this ->atLeastOnce ())
149
171
->method ('isAllowed ' )
150
172
->with ('Magento_Cms::media_gallery ' )
@@ -161,6 +183,8 @@ public function testGetConfig($data, $isAuthorizationAllowed, $expectedResults)
161
183
$ this ->assertEquals ($ expectedResults [0 ], $ config ->getData ('someData ' ));
162
184
$ this ->assertEquals ($ expectedResults [1 ], $ config ->getData ('wysiwygPluginSettings ' ));
163
185
$ this ->assertEquals ($ expectedResults [2 ], $ config ->getData ('pluginSettings ' ));
186
+ $ this ->assertEquals ('localhost/pub/static/ ' , $ config ->getData ('baseStaticUrl ' ));
187
+ $ this ->assertEquals ('localhost/pub/static/ ' , $ config ->getData ('baseStaticDefaultUrl ' ));
164
188
}
165
189
166
190
public function getConfigDataProvider ()
0 commit comments