You are here

protected function DrupalOrgTest::setUp in Freelinking 8.3

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

Overrides UnitTestCase::setUp

File

tests/src/Unit/Plugin/freelinking/DrupalOrgTest.php, line 40

Class

DrupalOrgTest
Tests the drupalorg 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 on drupal.org.');
  $this->translationInterfaceMock = $tProphet
    ->reveal();

  // Mock module handler service.
  $moduleHandlerProphet = $this
    ->prophesize('\\Drupal\\Core\\Extension\\ModuleHandlerInterface');
  $moduleHandlerProphet
    ->moduleExists('search')
    ->willReturn(FALSE);
  $this->container = new ContainerBuilder();
  $this->container
    ->set('string_translation', $this->translationInterfaceMock);
  $this->container
    ->set('module_handler', $moduleHandlerProphet
    ->reveal());
  $this->container
    ->set('http_client', $this
    ->getGuzzleMock());
  \Drupal::setContainer($this->container);
}