Skip to content

Commit f83d14a

Browse files
committed
MAGETWO-88645: Error while deleting a Product Image
1 parent e4756d6 commit f83d14a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class UpdateHandlerTest extends \PHPUnit\Framework\TestCase
3636
/**
3737
* @var WriteInterface
3838
*/
39-
private $rootDirectory;
39+
private $mediaDirectory;
4040

4141
/**
4242
* @var Filesystem
@@ -53,21 +53,21 @@ class UpdateHandlerTest extends \PHPUnit\Framework\TestCase
5353
*/
5454
protected function setUp()
5555
{
56-
$this->fileName = 'test.txt';
56+
$this->fileName = 'image.txt';
5757

5858
$this->objectManager = Bootstrap::getObjectManager();
5959
$this->updateHandler = $this->objectManager->create(UpdateHandler::class);
6060
$this->filesystem = $this->objectManager->get(Filesystem::class);
61-
$this->rootDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::ROOT);
62-
$this->rootDirectory->writeFile($this->rootDirectory->getAbsolutePath($this->fileName), 'Test');
61+
$this->mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
62+
$this->mediaDirectory->writeFile($this->mediaDirectory->getRelativePath($this->fileName), 'Test');
6363
}
6464

6565
/**
6666
* @return void
6767
*/
6868
public function testExecuteWithIllegalFilename(): void
6969
{
70-
$filePath = str_repeat('/..', 9) . '/' . $this->fileName;
70+
$filePath = str_repeat('/..', 2) . DIRECTORY_SEPARATOR . $this->fileName;
7171

7272
/** @var $product Product */
7373
$product = Bootstrap::getObjectManager()->create(Product::class);
@@ -87,14 +87,14 @@ public function testExecuteWithIllegalFilename(): void
8787
);
8888

8989
$this->updateHandler->execute($product);
90-
$this->assertFileExists($this->rootDirectory->getAbsolutePath($this->fileName));
90+
$this->assertFileExists($this->mediaDirectory->getAbsolutePath($this->fileName));
9191
}
9292

9393
/**
9494
* @return void
9595
*/
9696
protected function tearDown(): void
9797
{
98-
$this->rootDirectory->getDriver()->deleteFile($this->rootDirectory->getAbsolutePath($this->fileName));
98+
$this->mediaDirectory->getDriver()->deleteFile($this->mediaDirectory->getAbsolutePath($this->fileName));
9999
}
100100
}

0 commit comments

Comments
 (0)