FileSystemTempDirectoryTest.php in Drupal 10
File
core/tests/Drupal/KernelTests/Core/File/FileSystemTempDirectoryTest.php
View source
<?php
namespace Drupal\KernelTests\Core\File;
use Drupal\Component\FileSystem\FileSystem as FileSystemComponent;
use Drupal\Core\File\FileSystem;
use Drupal\KernelTests\KernelTestBase;
class FileSystemTempDirectoryTest extends KernelTestBase {
protected static $modules = [
'system',
];
protected $fileSystem;
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);
}
public function testGetTempDirectorySettings() {
$tempDir = '/var/tmp/' . $this
->randomMachineName();
$this
->setSetting('file_temp_path', $tempDir);
$this
->assertEquals($tempDir, $this->fileSystem
->getTempDirectory());
}
public function testGetTempDirectoryOsDefault() {
$tempDir = FileSystemComponent::getOsTemporaryDirectory();
$dir = $this->fileSystem
->getTempDirectory();
$this
->assertEquals($tempDir, $dir);
}
}