You are here

FileLogTestBase.php in File Log 2.0.x

Same filename and directory in other branches
  1. 8 tests/src/Unit/FileLogTestBase.php

File

tests/src/Unit/FileLogTestBase.php
View source
<?php

namespace Drupal\Tests\filelog\Unit;

use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\File\FileSystem;
use Drupal\Core\Site\Settings;
use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
use Drupal\Tests\UnitTestCase;
use org\bovigo\vfs\vfsStream;
use Psr\Log\LoggerInterface;

/**
 * Base class for file-base filelog tests.
 */
abstract class FileLogTestBase extends UnitTestCase {

  /**
   * The virtual file system, for manipulating files in-memory.
   *
   * @var \org\bovigo\vfs\vfsStreamDirectory
   */
  protected $virtualFileSystem;

  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    $container = new ContainerBuilder();

    /** @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface $swManager */
    $swManager = $this
      ->createMock(StreamWrapperManagerInterface::class);
    $settings = new Settings([]);

    /** @var \Psr\Log\LoggerInterface $logger */
    $logger = $this
      ->createMock(LoggerInterface::class);
    $this->fileSystem = new FileSystem($swManager, $settings, $logger);
    $container
      ->set('file_system', $this->fileSystem);
    \Drupal::setContainer($container);
    $this->virtualFileSystem = vfsStream::setup('filelog');
  }

}

Classes

Namesort descending Description
FileLogTestBase Base class for file-base filelog tests.