Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not create a subfolder with the same name as the main folder #27976

Merged
merged 1 commit into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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