You are here

protected function FileTest::setUp in Freelinking 4.0.x

Same name and namespace in other branches
  1. 8.3 tests/src/Unit/Plugin/freelinking/FileTest.php \Drupal\Tests\freelinking\Unit\Plugin\freelinking\FileTest::setUp()

Overrides UnitTestCase::setUp

File

tests/src/Unit/Plugin/freelinking/FileTest.php, line 39

Class

FileTest
Tests the freelinking file plugin.

Namespace

Drupal\Tests\freelinking\Unit\Plugin\freelinking

Code

protected function setUp() {

  // Mock string translation service.
  $tProphet = $this
    ->prophesize('\\Drupal\\Core\\StringTranslation\\TranslationInterface');
  $tProphet
    ->translateString(Argument::any())
    ->willReturn('Click to view a local file.');
  $this->translationInterfaceMock = $tProphet
    ->reveal();

  // Mock Immutable Config.
  $configProphet = $this
    ->prophesize('\\Drupal\\Core\\Config\\ImmutableConfig');
  $configProphet
    ->get('default_scheme')
    ->willReturn('public');

  // Mock configuration factory.
  $configFactoryProphet = $this
    ->prophesize('\\Drupal\\Core\\Config\\ConfigFactoryInterface');
  $configFactoryProphet
    ->get('system.file')
    ->willReturn($configProphet
    ->reveal());
  $this->container = new ContainerBuilder();
  $this->container
    ->set('string_translation', $this->translationInterfaceMock);
  $this->container
    ->set('module_handler', $this
    ->getModuleHandlerMock());
  $this->container
    ->set('config.factory', $configFactoryProphet
    ->reveal());
  $this->container
    ->set('stream_wrapper_manager', $this
    ->getStreamWrapperMock());
  \Drupal::setContainer($this->container);
}