Skip to content

Commit 421fdc4

Browse files
author
Hwashiang Yu
committed
MC-31362: Media folder update
- Fixed unit test failures - Fixed minor invalid logic in filedriver
1 parent a050516 commit 421fdc4

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ protected function setUp()
139139

140140
$this->directoryMock = $this->createPartialMock(
141141
\Magento\Framework\Filesystem\Directory\Write::class,
142-
['delete', 'getDriver', 'create', 'getRelativePath', 'isExist', 'isFile']
142+
['delete', 'getDriver', 'create', 'getRelativePath', 'getAbsolutePath', 'isExist', 'isFile']
143143
);
144144
$this->directoryMock->expects(
145145
$this->any()
@@ -283,6 +283,7 @@ public function testGetResizeHeight()
283283
public function testDeleteDirectoryOverRoot()
284284
{
285285
$this->driverMock->expects($this->atLeastOnce())->method('getRealPathSafety')->will($this->returnArgument(0));
286+
$this->directoryMock->expects($this->atLeastOnce())->method('getAbsolutePath')->will($this->returnArgument(0));
286287
$this->imagesStorage->deleteDirectory(self::INVALID_DIRECTORY_OVER_ROOT);
287288
}
288289

@@ -294,6 +295,7 @@ public function testDeleteDirectoryOverRoot()
294295
public function testDeleteRootDirectory()
295296
{
296297
$this->driverMock->expects($this->atLeastOnce())->method('getRealPathSafety')->will($this->returnArgument(0));
298+
$this->directoryMock->expects($this->atLeastOnce())->method('getAbsolutePath')->will($this->returnArgument(0));
297299
$this->imagesStorage->deleteDirectory(self::STORAGE_ROOT_DIR);
298300
}
299301

lib/internal/Magento/Framework/Filesystem/Driver/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ public function getRealPathSafety($path)
984984
);
985985
$pathParts = explode(DIRECTORY_SEPARATOR, $path);
986986
if (end($pathParts) == '.') {
987-
$pathParts[count($pathParts)] = '';
987+
$pathParts[count($pathParts) - 1] = '';
988988
}
989989
$realPath = [];
990990
foreach ($pathParts as $pathPart) {

lib/internal/Magento/Framework/Filesystem/Test/Unit/Driver/FileTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,14 @@ public function dataProviderForTestGetRealPathSafety(): array
107107
{
108108
return [
109109
['/1/2/3', '/1/2/3'],
110+
['/1/.test', '/1/.test'],
111+
['/1/..test', '/1/..test'],
112+
['/1/.test/.test', '/1/.test/.test'],
113+
['/1/2/./.', '/1/2/'],
110114
['/1/2/3/../..', '/1'],
111-
['/1/2/3/.', '/1/2/3'],
115+
['/1/2/3/.', '/1/2/3/'],
112116
['/1/2/3/./4/5', '/1/2/3/4/5'],
113-
['/1/2/3/../4/5', '/1/2/4/5'],
117+
['/1/2/3/../4/5', '/1/2/4/5']
114118
];
115119
}
116120
}

0 commit comments

Comments
 (0)