Skip to content

Commit

Permalink
ENGCOM-7490: Can not create a subfolder with the same name as the mai…
Browse files Browse the repository at this point in the history
…n folder #27976
  • Loading branch information
slavvka committed Apr 27, 2020
2 parents dfb00d6 + bf6cf85 commit 5dd3acf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function execute(array $paths): void
//phpcs:ignore Magento2.Functions.DiscouragedFunction
$name = basename($path);
//phpcs:ignore Magento2.Functions.DiscouragedFunction
$folder = str_replace($name, '', $path);
$folder = substr($path, 0, strrpos($path, $name));

$this->storage->createDirectory(
$name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,24 @@ public function notAllowedPathsProvider(): array
];
}

/**
* Test create child directory with the same name as parent
*/
public function testCreateChildDirectoryTheSameNameAsParentDirectory(): void
{
$dir = self::TEST_DIRECTORY_NAME;
$childPath = $dir . '/' . $dir;

$this->createByPaths->execute([$dir]);
$this->assertFileExists($this->mediaDirectoryPath . $dir);
$this->createByPaths->execute([$childPath]);
$this->assertFileExists($this->mediaDirectoryPath . $childPath);
}

/**
* @throws \Magento\Framework\Exception\FileSystemException
*/
public static function tearDownAfterClass()
protected function tearDown()
{
$filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->get(\Magento\Framework\Filesystem::class);
Expand Down

0 comments on commit 5dd3acf

Please sign in to comment.