You are here

public function LinkcheckerRepair301Test::setUp in Link checker 8

Overrides KernelTestBase::setUp

File

tests/src/Kernel/LinkcheckerRepair301Test.php, line 83

Class

LinkcheckerRepair301Test
Test for Repair on 301 status handling.

Namespace

Drupal\Tests\linkchecker\Kernel

Code

public function setUp() {
  parent::setUp();
  $this
    ->installSchema('system', 'sequences');
  $this
    ->installSchema('node', 'node_access');
  $this
    ->installSchema('linkchecker', 'linkchecker_index');
  $this
    ->installEntitySchema('user');
  $this
    ->installEntitySchema('node');
  $this
    ->installEntitySchema('linkcheckerlink');
  $this
    ->installConfig([
    'field',
    'user',
    'node',
    'filter',
    'linkchecker',
  ]);
  $this->checkerService = $this->container
    ->get('linkchecker.checker');
  $this->linkcheckerSetting = $this->container
    ->get('config.factory')
    ->getEditable('linkchecker.settings');
  $this->repair301 = $this->container
    ->get('plugin.manager.link_status_handler')
    ->createInstance('repair_301');
  $this->request = $this->container
    ->get('request_stack')
    ->getCurrentRequest();
  if (isset($this->request)) {
    $this->httpProtocol = $this->request
      ->getScheme() . '://';
    $this->baseUrl = $this->request
      ->getSchemeAndHttpHost() . $this->request
      ->getBasePath();
  }
  else {
    $this->httpProtocol = $this->linkcheckerSetting
      ->get('default_url_scheme');
    $this->baseUrl = $this->httpProtocol . $this->linkcheckerSetting
      ->get('base_path');
  }
}