-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
781e5f4
commit 66d2cbc
Showing
6 changed files
with
233 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
dev/tests/integration/testsuite/Magento/Framework/Filesystem/Io/FileTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
/** | ||
* Test for \Magento\Framework\Filesystem\Io\File | ||
* | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Framework\Filesystem\Io; | ||
|
||
use Magento\Framework\Exception\FileSystemException; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Verify filesystem client | ||
*/ | ||
class FileTest extends TestCase | ||
{ | ||
|
||
/** | ||
* @var File | ||
*/ | ||
private $io; | ||
|
||
/** | ||
* @var String | ||
*/ | ||
private $absolutePath; | ||
|
||
/** | ||
* @var String | ||
*/ | ||
private $generatedPath; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function setUp() | ||
{ | ||
$this->io = new File(); | ||
$this->absolutePath = Bootstrap::getInstance()->getAppTempDir(); | ||
$this->generatedPath = $this->getTestPath('/rollback_test_'); | ||
$this->io->mkdir($this->generatedPath); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
* | ||
* @return void | ||
*/ | ||
protected function tearDown(): void | ||
{ | ||
$this->removeGeneratedDirectory(); | ||
} | ||
|
||
/** | ||
* Verify file put without content. | ||
* | ||
* @return void | ||
*/ | ||
public function testWrite(): void | ||
{ | ||
$path = $this->generatedPath . '/file_three.txt'; | ||
$this->assertEquals(0, $this->io->write($path, '', 0444)); | ||
$this->assertEquals(false, is_writable($path)); | ||
} | ||
|
||
/** | ||
* Returns relative path for the test. | ||
* | ||
* @param $relativePath | ||
* @return string | ||
*/ | ||
protected function getTestPath($relativePath): string | ||
{ | ||
return $this->absolutePath . $relativePath . time(); | ||
} | ||
|
||
/** | ||
* Remove generated directories. | ||
* | ||
* @return void | ||
*/ | ||
private function removeGeneratedDirectory(): void | ||
{ | ||
if (is_dir($this->generatedPath)) { | ||
$this->io->rmdir($this->generatedPath, true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.