You are here

protected function DecoupledRouterFunctionalTest::setUp in Decoupled Router 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/DecoupledRouterFunctionalTest.php \Drupal\Tests\decoupled_router\Functional\DecoupledRouterFunctionalTest::setUp()

Overrides BrowserTestBase::setUp

File

tests/src/Functional/DecoupledRouterFunctionalTest.php, line 53

Class

DecoupledRouterFunctionalTest
Test class.

Namespace

Drupal\Tests\decoupled_router\Functional

Code

protected function setUp() {
  parent::setUp();
  $language = ConfigurableLanguage::createFromLangcode('ca');
  $language
    ->save();

  // In order to reflect the changes for a multilingual site in the container
  // we have to rebuild it.
  $this
    ->rebuildContainer();
  \Drupal::configFactory()
    ->getEditable('language.negotiation')
    ->set('url.prefixes.ca', 'ca')
    ->save();
  $this
    ->drupalCreateContentType([
    'type' => 'article',
    'name' => 'Article',
  ]);
  $this->user = $this
    ->drupalCreateUser([
    'access content',
    'create article content',
    'edit any article content',
    'delete any article content',
  ]);
  $this
    ->createDefaultContent(3);
  $redirect = Redirect::create([
    'status_code' => '301',
  ]);
  $redirect
    ->setSource('/foo');
  $redirect
    ->setRedirect('/node--0');
  $redirect
    ->setLanguage(Language::LANGCODE_NOT_SPECIFIED);
  $redirect
    ->save();
  $redirect = Redirect::create([
    'status_code' => '301',
  ]);
  $redirect
    ->setSource('/bar');
  $redirect
    ->setRedirect('/foo');
  $redirect
    ->setLanguage(Language::LANGCODE_NOT_SPECIFIED);
  $redirect
    ->save();
  $redirect = Redirect::create([
    'status_code' => '301',
  ]);
  $redirect
    ->setSource('/foo--ca');
  $redirect
    ->setRedirect('/node--0--ca');
  $redirect
    ->setLanguage('ca');
  $redirect
    ->save();
  \Drupal::service('router.builder')
    ->rebuild();
}