Skip to content

Commit b3529b6

Browse files
committed
MAGETWO-95629: Filesystem Directory Improvement
1 parent a2afbc3 commit b3529b6

File tree

14 files changed

+855
-23
lines changed

14 files changed

+855
-23
lines changed

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/UploaderTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ protected function setUp()
4646
$mediaPath = $appParams[DirectoryList::MEDIA][DirectoryList::PATH];
4747
$this->directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
4848
$tmpDir = $this->directory->getRelativePath($mediaPath . '/import');
49+
$this->directory->create($tmpDir);
4950
$this->uploader->setTmpDir($tmpDir);
5051

5152
parent::setUp();
@@ -75,4 +76,18 @@ public function testMoveWithInvalidFile()
7576
$this->uploader->move($fileName);
7677
$this->assertFalse($this->directory->isExist($this->uploader->getTmpDir() . '/' . $fileName));
7778
}
79+
80+
/**
81+
* @inheritdoc
82+
*/
83+
public static function tearDownAfterClass()
84+
{
85+
$filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
86+
->get(\Magento\Framework\Filesystem::class);
87+
/** @var \Magento\Framework\Filesystem\Directory\WriteInterface $directory */
88+
$directory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
89+
if ($directory->isExist('import')) {
90+
$directory->delete('import');
91+
}
92+
}
7893
}

dev/tests/integration/testsuite/Magento/Framework/App/Filesystem/DirectoryResolverTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Framework\App\Filesystem;
88

9+
use Magento\Framework\App\Filesystem\DirectoryList;
910
use Magento\TestFramework\Helper\Bootstrap;
1011

1112
/**
@@ -24,9 +25,9 @@ class DirectoryResolverTest extends \PHPUnit\Framework\TestCase
2425
private $directoryResolver;
2526

2627
/**
27-
* @var \Magento\Framework\Filesystem\Directory\WriteInterface
28+
* @var \Magento\Framework\Filesystem
2829
*/
29-
private $directory;
30+
private $filesystem;
3031

3132
/**
3233
* @inheritdoc
@@ -36,9 +37,7 @@ protected function setUp()
3637
$this->objectManager = Bootstrap::getObjectManager();
3738
$this->directoryResolver = $this->objectManager
3839
->create(\Magento\Framework\App\Filesystem\DirectoryResolver::class);
39-
/** @var \Magento\Framework\Filesystem $filesystem */
40-
$filesystem = $this->objectManager->create(\Magento\Framework\Filesystem::class);
41-
$this->directory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);
40+
$this->filesystem = $this->objectManager->create(\Magento\Framework\Filesystem::class);
4241
}
4342

4443
/**
@@ -51,7 +50,8 @@ protected function setUp()
5150
*/
5251
public function testValidatePath($path, $directoryConfig, $expectation)
5352
{
54-
$path = $this->directory->getAbsolutePath($path);
53+
$directory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
54+
$path = $directory->getAbsolutePath() .'/' .$path;
5555
$this->assertEquals($expectation, $this->directoryResolver->validatePath($path, $directoryConfig));
5656
}
5757

@@ -62,7 +62,8 @@ public function testValidatePath($path, $directoryConfig, $expectation)
6262
*/
6363
public function testValidatePathWithException()
6464
{
65-
$path = $this->directory->getAbsolutePath();
65+
$directory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
66+
$path = $directory->getAbsolutePath();
6667
$this->directoryResolver->validatePath($path, 'wrong_dir');
6768
}
6869

0 commit comments

Comments
 (0)