class FileSystemTempDirectoryTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/File/FileSystemTempDirectoryTest.php \Drupal\KernelTests\Core\File\FileSystemTempDirectoryTest
- 10 core/tests/Drupal/KernelTests/Core/File/FileSystemTempDirectoryTest.php \Drupal\KernelTests\Core\File\FileSystemTempDirectoryTest
- 8.9.x core/tests/Drupal/KernelTests/Core/File/FileSystemTempDirectoryTest.php \Drupal\KernelTests\Core\File\FileSystemTempDirectoryTest
Tests for getTempDirectory on FileSystem.
@group File
@coversDefaultClass \Drupal\Core\File\FileSystem
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\File\FileSystemTempDirectoryTest implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of FileSystemTempDirectoryTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ File/ FileSystemTempDirectoryTest.php, line 15
Namespace
Drupal\KernelTests\Core\FileView source
class FileSystemTempDirectoryTest extends KernelTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'system',
];
/**
* The file system under test.
*
* @var \Drupal\Core\File\FileSystemInterface
*/
protected $fileSystem;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$stream_wrapper_manager = $this->container
->get('stream_wrapper_manager');
$logger = $this->container
->get('logger.channel.file');
$settings = $this->container
->get('settings');
$this->fileSystem = new FileSystem($stream_wrapper_manager, $settings, $logger);
}
/**
* Tests 'file_temp_path' setting.
*
* @covers ::getTempDirectory
*/
public function testGetTempDirectorySettings() {
$tempDir = '/var/tmp/' . $this->randomMachineName();
$this->setSetting('file_temp_path', $tempDir);
$this->assertEquals($tempDir, $this->fileSystem
->getTempDirectory());
}
/**
* Tests os default fallback.
*
* @covers ::getTempDirectory
*/
public function testGetTempDirectoryOsDefault() {
$tempDir = FileSystemComponent::getOsTemporaryDirectory();
$dir = $this->fileSystem
->getTempDirectory();
$this->assertEquals($tempDir, $dir);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.