Skip to content

Commit 1647eb4

Browse files
author
OlgaVasyltsun
committed
MC-18099: Changes in Downloadable product upload controller
1 parent b5b0e91 commit 1647eb4

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

dev/tests/integration/testsuite/Magento/Framework/File/UploaderTest.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public function testUploadFileFromAllowedFolder(): void
4747
$fileName = 'text.txt';
4848
$tmpDir = 'tmp';
4949
$filePath = $tmpDirectory->getAbsolutePath($fileName);
50-
$file = fopen($filePath, "wb");
51-
fwrite($file, 'just a text');
50+
51+
$tmpDirectory->writeFile($fileName, 'just a text');
5252

5353
$type = [
5454
'tmp_name' => $filePath,
@@ -58,7 +58,7 @@ public function testUploadFileFromAllowedFolder(): void
5858
$uploader = $this->uploaderFactory->create(['fileId' => $type]);
5959
$uploader->save($mediaDirectory->getAbsolutePath($tmpDir));
6060

61-
$this->assertTrue(is_file($mediaDirectory->getAbsolutePath($tmpDir . DIRECTORY_SEPARATOR . $fileName)));
61+
$this->assertTrue($mediaDirectory->isFile($tmpDir . DIRECTORY_SEPARATOR . $fileName));
6262
}
6363

6464
/**
@@ -72,13 +72,9 @@ public function testUploadFileFromNotAllowedFolder(): void
7272
$fileName = 'text.txt';
7373
$tmpDir = 'tmp';
7474
$tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::LOG);
75-
$directoryPath = $tmpDirectory->getAbsolutePath() . $tmpDir;
76-
if (!is_dir($directoryPath)) {
77-
mkdir($directoryPath, 0777, true);
78-
}
79-
$filePath = $directoryPath . DIRECTORY_SEPARATOR . $fileName;
80-
$file = fopen($filePath, "wb");
81-
fwrite($file, 'just a text');
75+
$filePath = $tmpDirectory->getAbsolutePath() . $tmpDir . DIRECTORY_SEPARATOR . $fileName;
76+
77+
$tmpDirectory->writeFile($tmpDir . DIRECTORY_SEPARATOR . $fileName, 'just a text');
8278

8379
$type = [
8480
'tmp_name' => $filePath,
@@ -91,15 +87,17 @@ public function testUploadFileFromNotAllowedFolder(): void
9187
/**
9288
* @inheritdoc
9389
*/
94-
protected function tearDown()
90+
public static function tearDownAfterClass()
9591
{
96-
parent::tearDown();
92+
parent::tearDownAfterClass();
93+
$filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
94+
->get(\Magento\Framework\Filesystem::class);
9795

9896
$tmpDir = 'tmp';
99-
$mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
97+
$mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
10098
$mediaDirectory->delete($tmpDir);
10199

102-
$logDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::LOG);
100+
$logDirectory = $filesystem->getDirectoryWrite(DirectoryList::LOG);
103101
$logDirectory->delete($tmpDir);
104102
}
105103
}

0 commit comments

Comments
 (0)