Skip to content

Commit 9e43510

Browse files
Fixed the issue, added unit test
1 parent 72239c5 commit 9e43510

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

app/code/Magento/AwsS3/Driver/AwsS3.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,10 @@ public function getRealPath($path)
524524
*/
525525
public function rename($oldPath, $newPath, DriverInterface $targetDriver = null): bool
526526
{
527+
if ($oldPath === $newPath) {
528+
return true;
529+
}
530+
527531
try {
528532
$this->adapter->move(
529533
$this->normalizeRelativePath($oldPath, true),

app/code/Magento/AwsS3/Test/Unit/Driver/AwsS3Test.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,4 +496,21 @@ public function testCreateDirectory(): void
496496

497497
self::assertTrue($this->driver->createDirectory(self::URL . 'test/test2/'));
498498
}
499+
500+
public function testRename(): void
501+
{
502+
$this->adapterMock->expects(self::once())
503+
->method('move')
504+
->with('test/path', 'test/path2');
505+
506+
self::assertTrue($this->driver->rename('test/path', 'test/path2'));
507+
}
508+
509+
public function testRenameSameDestination(): void
510+
{
511+
$this->adapterMock->expects(self::never())
512+
->method('move');
513+
514+
self::assertTrue($this->driver->rename('test/path', 'test/path'));
515+
}
499516
}

0 commit comments

Comments
 (0)