Skip to content

Commit 943a37e

Browse files
committed
Merge branch 'MAGETWO-64587' of github.com:magento-troll/magento2ce into MAGETWO-62334
2 parents 59f16b8 + d115107 commit 943a37e

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

app/code/Magento/Catalog/Model/View/Asset/Image.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function getContentType()
9595
*/
9696
public function getPath()
9797
{
98-
return $this->getRelativePath($this->context->getPath());
98+
return $this->getAbsolutePath($this->context->getPath());
9999
}
100100

101101
/**
@@ -175,6 +175,21 @@ private function getMiscPath()
175175
return $this->encryptor->hash(implode('_', $this->miscParams), Encryptor::HASH_VERSION_MD5);
176176
}
177177

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+
178193
/**
179194
* Generate relative path
180195
*

app/code/Magento/Catalog/Test/Unit/Model/View/Asset/ImageTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,30 @@ public function testGetPath($filePath, $miscParams)
9797
);
9898
}
9999

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+
100124
/**
101125
* @param string $filePath
102126
* @param array $miscParams

0 commit comments

Comments
 (0)