@@ -27,7 +27,10 @@ public function testGetStorageRoot()
27
27
\Magento \Framework \Filesystem::class
28
28
);
29
29
$ mediaPath = $ filesystem ->getDirectoryRead (DirectoryList::MEDIA )->getAbsolutePath ();
30
- $ helper = $ this ->generateHelper (null );
30
+ /** @var \Magento\Cms\Helper\Wysiwyg\Images $helper */
31
+ $ helper = $ this ->objectManager ->create (
32
+ \Magento \Cms \Helper \Wysiwyg \Images::class
33
+ );
31
34
$ this ->assertStringStartsWith ($ mediaPath , $ helper ->getStorageRoot ());
32
35
}
33
36
@@ -36,7 +39,10 @@ public function testGetStorageRoot()
36
39
*/
37
40
public function testGetCurrentUrl ()
38
41
{
39
- $ helper = $ this ->generateHelper (null );
42
+ /** @var \Magento\Cms\Helper\Wysiwyg\Images $helper */
43
+ $ helper = $ this ->objectManager ->create (
44
+ \Magento \Cms \Helper \Wysiwyg \Images::class
45
+ );
40
46
$ this ->assertStringStartsWith ('http://example.com/ ' , $ helper ->getCurrentUrl ());
41
47
}
42
48
@@ -98,37 +104,33 @@ function ($actualResult) {
98
104
/**
99
105
* Generate instance of Images Helper
100
106
*
101
- * @param bool|null $isStaticUrlsAllowed - if boolean, mock is created to override value of isUsingStaticUrlsAllowed
107
+ * @param bool $isStaticUrlsAllowed - mock is created to override value of isUsingStaticUrlsAllowed method in class
102
108
* @return \Magento\Cms\Helper\Wysiwyg\Images
103
109
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
104
110
*/
105
111
private function generateHelper ($ isStaticUrlsAllowed = false )
106
112
{
107
113
$ storeId = 1 ;
108
114
109
- if (!is_bool ($ isStaticUrlsAllowed )) {
110
- $ helper = $ this ->objectManager ->create (\Magento \Cms \Helper \Wysiwyg \Images::class);
111
- } else {
112
- $ eventManagerMock = $ this ->createMock (\Magento \Framework \Event \ManagerInterface::class);
115
+ $ eventManagerMock = $ this ->createMock (\Magento \Framework \Event \ManagerInterface::class);
113
116
114
- $ contextMock = $ this ->objectManager ->create (\Magento \Framework \App \Helper \Context::class, [
115
- 'eventManager ' => $ eventManagerMock ,
116
- ]);
117
+ $ contextMock = $ this ->objectManager ->create (\Magento \Framework \App \Helper \Context::class, [
118
+ 'eventManager ' => $ eventManagerMock ,
119
+ ]);
117
120
118
- $ helper = $ this ->objectManager ->create (\Magento \Cms \Helper \Wysiwyg \Images::class, [
119
- 'context ' => $ contextMock
120
- ]);
121
+ $ helper = $ this ->objectManager ->create (\Magento \Cms \Helper \Wysiwyg \Images::class, [
122
+ 'context ' => $ contextMock
123
+ ]);
121
124
122
- $ checkResult = new \stdClass ();
123
- $ checkResult ->isAllowed = false ;
125
+ $ checkResult = new \stdClass ();
126
+ $ checkResult ->isAllowed = false ;
124
127
125
- $ eventManagerMock ->expects ($ this ->any ())
126
- ->method ('dispatch ' )
127
- ->with ('cms_wysiwyg_images_static_urls_allowed ' , ['result ' => $ checkResult , 'store_id ' => $ storeId ])
128
- ->willReturnCallback (function ($ _ , $ arr ) use ($ isStaticUrlsAllowed ) {
129
- $ arr ['result ' ]->isAllowed = $ isStaticUrlsAllowed ;
130
- });
131
- }
128
+ $ eventManagerMock ->expects ($ this ->any ())
129
+ ->method ('dispatch ' )
130
+ ->with ('cms_wysiwyg_images_static_urls_allowed ' , ['result ' => $ checkResult , 'store_id ' => $ storeId ])
131
+ ->willReturnCallback (function ($ _ , $ arr ) use ($ isStaticUrlsAllowed ) {
132
+ $ arr ['result ' ]->isAllowed = $ isStaticUrlsAllowed ;
133
+ });
132
134
133
135
$ helper ->setStoreId ($ storeId );
134
136
0 commit comments