File tree 2 files changed +40
-1
lines changed
Test/Unit/Model/View/Asset 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ public function getContentType()
95
95
*/
96
96
public function getPath ()
97
97
{
98
- return $ this ->getRelativePath ($ this ->context ->getPath ());
98
+ return $ this ->getAbsolutePath ($ this ->context ->getPath ());
99
99
}
100
100
101
101
/**
@@ -175,6 +175,21 @@ private function getMiscPath()
175
175
return $ this ->encryptor ->hash (implode ('_ ' , $ this ->miscParams ), Encryptor::HASH_VERSION_MD5 );
176
176
}
177
177
178
+ /**
179
+ * Generate absolute path
180
+ *
181
+ * @param string $result
182
+ * @return string
183
+ */
184
+ private function getAbsolutePath ($ result )
185
+ {
186
+ $ prefix = (substr ($ result , 0 , 1 ) == DIRECTORY_SEPARATOR ) ? DIRECTORY_SEPARATOR : '' ;
187
+ $ result = $ this ->join ($ result , $ this ->getModule ());
188
+ $ result = $ this ->join ($ result , $ this ->getMiscPath ());
189
+ $ result = $ this ->join ($ result , $ this ->getFilePath ());
190
+ return $ prefix . $ result ;
191
+ }
192
+
178
193
/**
179
194
* Generate relative path
180
195
*
Original file line number Diff line number Diff line change @@ -97,6 +97,30 @@ public function testGetPath($filePath, $miscParams)
97
97
);
98
98
}
99
99
100
+ /**
101
+ * @param string $filePath
102
+ * @param array $miscParams
103
+ * @dataProvider getPathDataProvider
104
+ */
105
+ public function testGetNotUnixPath ($ filePath , $ miscParams )
106
+ {
107
+ $ imageModel = new Image (
108
+ $ this ->mediaConfig ,
109
+ $ this ->imageContext ,
110
+ $ this ->encryptor ,
111
+ $ filePath ,
112
+ $ miscParams
113
+ );
114
+ $ absolutePath = 'C:\www\magento2ce\pub\media\catalog\product ' ;
115
+ $ hashPath = md5 (implode ('_ ' , $ miscParams ));
116
+ $ this ->imageContext ->expects ($ this ->once ())->method ('getPath ' )->willReturn ($ absolutePath );
117
+ $ this ->encryptor ->expects ($ this ->once ())->method ('hash ' )->willReturn ($ hashPath );
118
+ $ this ->assertEquals (
119
+ $ absolutePath . DIRECTORY_SEPARATOR . 'cache ' . DIRECTORY_SEPARATOR . $ hashPath . $ filePath ,
120
+ $ imageModel ->getPath ()
121
+ );
122
+ }
123
+
100
124
/**
101
125
* @param string $filePath
102
126
* @param array $miscParams
You can’t perform that action at this time.
0 commit comments