FileSystem example

protected $streamWrapperManager;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $settings = new Settings([]);
    $this->streamWrapperManager = $this->createMock(StreamWrapperManagerInterface::class);
    $this->logger = $this->createMock('Psr\Log\LoggerInterface');
    $this->fileSystem = new FileSystem($this->streamWrapperManager, $settings$this->logger);
  }

  /** * @covers ::chmod */
  public function testChmodFile() {
    vfsStream::setup('dir');
    vfsStream::create(['test.txt' => 'asdf']);
    $uri = 'vfs://dir/test.txt';

    $this->assertTrue($this->fileSystem->chmod($uri));
    

  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());
  }
Home | Imprint | This part of the site doesn't use cookies.