@@ -27,32 +27,34 @@ public function testGetStorageRoot()
27
27
\Magento \Framework \Filesystem::class
28
28
);
29
29
$ mediaPath = $ filesystem ->getDirectoryRead (DirectoryList::MEDIA )->getAbsolutePath ();
30
- $ helper = $ this ->generateHelper ();
30
+ $ helper = $ this ->generateHelper (null );
31
31
$ this ->assertStringStartsWith ($ mediaPath , $ helper ->getStorageRoot ());
32
32
}
33
33
34
+ /**
35
+ * @magentoConfigFixture current_store web/unsecure/base_url http://example.com/
36
+ */
34
37
public function testGetCurrentUrl ()
35
38
{
36
- $ helper = $ this ->generateHelper ();
37
- $ this ->assertStringStartsWith ('http://localhost / ' , $ helper ->getCurrentUrl ());
39
+ $ helper = $ this ->generateHelper (null );
40
+ $ this ->assertStringStartsWith ('http://example.com / ' , $ helper ->getCurrentUrl ());
38
41
}
39
42
40
43
/**
41
- * @param bool $staticUrlsAllowed
44
+ * @param bool $isStaticUrlsAllowed
42
45
* @param string $filename
43
46
* @param bool $renderAsTag
44
47
* @param string|callable $expectedResult - string or callable to make unique assertions on $expectedResult
45
- *
46
48
* @magentoConfigFixture current_store web/unsecure/base_url http://example.com/
47
49
* @dataProvider providerGetImageHtmlDeclaration
48
50
*/
49
51
public function testGetImageHtmlDeclaration (
50
- $ staticUrlsAllowed ,
52
+ $ isStaticUrlsAllowed ,
51
53
$ filename ,
52
54
$ renderAsTag ,
53
55
$ expectedResult
54
56
) {
55
- $ helper = $ this ->generateHelper ($ staticUrlsAllowed );
57
+ $ helper = $ this ->generateHelper ($ isStaticUrlsAllowed );
56
58
57
59
$ actualResult = $ helper ->getImageHtmlDeclaration ($ filename , $ renderAsTag );
58
60
@@ -96,38 +98,39 @@ function ($actualResult) {
96
98
/**
97
99
* Generate instance of Images Helper
98
100
*
99
- * @param bool|null $staticUrlsAllowed - if boolean, mock is created to override value of isUsingStaticUrlsAllowed
101
+ * @param bool|null $isStaticUrlsAllowed - if boolean, mock is created to override value of isUsingStaticUrlsAllowed
100
102
* @return \Magento\Cms\Helper\Wysiwyg\Images
101
103
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
102
104
*/
103
- private function generateHelper ($ staticUrlsAllowed = null )
105
+ private function generateHelper ($ isStaticUrlsAllowed = false )
104
106
{
105
- if (!is_bool ($ staticUrlsAllowed )) {
106
- return $ this ->objectManager ->create (\Magento \Cms \Helper \Wysiwyg \Images::class);
107
- }
107
+ $ storeId = 1 ;
108
108
109
- $ eventManagerMock = $ this ->createMock (\Magento \Framework \Event \ManagerInterface::class);
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);
110
113
111
- $ contextMock = $ this ->objectManager ->create (\Magento \Framework \App \Helper \Context::class, [
112
- 'eventManager ' => $ eventManagerMock ,
113
- ]);
114
+ $ contextMock = $ this ->objectManager ->create (\Magento \Framework \App \Helper \Context::class, [
115
+ 'eventManager ' => $ eventManagerMock ,
116
+ ]);
114
117
115
- $ helper = $ this ->objectManager ->create (\Magento \Cms \Helper \Wysiwyg \Images::class, [
116
- 'context ' => $ contextMock
117
- ]);
118
+ $ helper = $ this ->objectManager ->create (\Magento \Cms \Helper \Wysiwyg \Images::class, [
119
+ 'context ' => $ contextMock
120
+ ]);
118
121
119
- $ storeId = 1 ;
120
- $ helper -> setStoreId ( $ storeId ) ;
122
+ $ checkResult = new \ stdClass () ;
123
+ $ checkResult -> isAllowed = false ;
121
124
122
- $ checkResult = new \stdClass ();
123
- $ checkResult ->isAllowed = false ;
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
+ }
124
132
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 ($ staticUrlsAllowed ) {
129
- $ arr ['result ' ]->isAllowed = $ staticUrlsAllowed ;
130
- });
133
+ $ helper ->setStoreId ($ storeId );
131
134
132
135
return $ helper ;
133
136
}
0 commit comments