Skip to content

Commit 7a1cbcc

Browse files
author
Oleksandr Gorkun
committed
MAGETWO-88432: Filesystem Directory Improvement
1 parent ce5eacd commit 7a1cbcc

File tree

19 files changed

+781
-544
lines changed

19 files changed

+781
-544
lines changed

app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Delete.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@ public function execute()
5353
$sitemap->load($id);
5454
// delete file
5555
$sitemapPath = $sitemap->getSitemapPath();
56+
if ($sitemapPath && $sitemapPath[0] === DIRECTORY_SEPARATOR) {
57+
$sitemapPath = mb_substr($sitemapPath, 1);
58+
}
5659
$sitemapFilename = $sitemap->getSitemapFilename();
57-
58-
$path = $directory->getRelativePath($sitemapPath . $sitemapFilename);
60+
$path = $directory->getRelativePath(
61+
$sitemapPath .$sitemapFilename
62+
);
5963
if ($sitemap->getSitemapFilename() && $directory->isFile($path)) {
6064
$directory->delete($path);
6165
}

app/code/Magento/Sitemap/Test/Unit/Controller/Adminhtml/Sitemap/DeleteTest.php

Lines changed: 0 additions & 149 deletions
This file was deleted.

dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFilesTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,7 @@ public function testExecuteWithWrongFileName()
101101
$this->model->getStorage()->getSession()->setCurrentPath($this->fullDirectoryPath);
102102
$this->model->execute();
103103

104-
$this->assertTrue(
105-
$this->mediaDirectory->isExist(
106-
$this->mediaDirectory->getRelativePath($this->fullDirectoryPath . $fileName)
107-
)
108-
);
104+
$this->assertFileExists($this->fullDirectoryPath . $fileName);
109105
}
110106

111107
/**

dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFolderTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,7 @@ public function testExecuteWithWrongDirectoryName()
112112
$this->model->getRequest()->setParams(['node' => $this->imagesHelper->idEncode($directoryName)]);
113113
$this->model->execute();
114114

115-
$this->assertTrue(
116-
$this->mediaDirectory->isExist(
117-
$this->mediaDirectory->getRelativePath($this->fullDirectoryPath . $directoryName)
118-
)
119-
);
115+
$this->assertFileExists($this->fullDirectoryPath . $directoryName);
120116
}
121117

122118
/**

dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/NewFolderTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,8 @@ public function testExecuteWithWrongPath()
111111
$this->model->getStorage()->getSession()->setCurrentPath($this->fullDirectoryPath . $dirPath);
112112
$this->model->execute();
113113

114-
$this->assertFalse(
115-
$this->mediaDirectory->isExist(
116-
$this->mediaDirectory->getRelativePath($this->fullDirectoryPath . $dirPath . $this->dirName)
117-
)
114+
$this->assertFileNotExists(
115+
$this->fullDirectoryPath . $dirPath . $this->dirName
118116
);
119117
}
120118

dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/UploadTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,8 @@ public function testExecuteWithWrongPath()
125125
$this->model->getStorage()->getSession()->setCurrentPath($dirPath);
126126
$this->model->execute();
127127

128-
$this->assertFalse(
129-
$this->mediaDirectory->isExist(
130-
$this->mediaDirectory->getRelativePath($this->fullDirectoryPath . $dirPath . $this->fileName)
131-
)
128+
$this->assertFileNotExists(
129+
$this->fullDirectoryPath . $dirPath . $this->fileName
132130
);
133131
}
134132

@@ -147,11 +145,7 @@ public function testExecuteWithWrongFileName()
147145
$this->model->getStorage()->getSession()->setCurrentPath($this->fullDirectoryPath);
148146
$this->model->execute();
149147

150-
$this->assertFalse(
151-
$this->mediaDirectory->isExist(
152-
$this->mediaDirectory->getRelativePath($this->fullDirectoryPath . $newFilename)
153-
)
154-
);
148+
$this->assertFileNotExists($this->fullDirectoryPath . $newFilename);
155149
}
156150

157151
/**

dev/tests/integration/testsuite/Magento/Framework/App/Filesystem/DirectoryResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function testValidatePath($path, $directoryConfig, $expectation)
5252
{
5353
$directory = $this->filesystem
5454
->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);
55-
$path = $directory->getAbsolutePath($path);
55+
$path = $directory->getAbsolutePath() .'/' .$path;
5656
$this->assertEquals($expectation, $this->directoryResolver->validatePath($path, $directoryConfig));
5757
}
5858

0 commit comments

Comments
 (0)