You are here

protected function GlobalRedirectTest::setUp in Redirect 8

Overrides BrowserTestBase::setUp

File

tests/src/Functional/GlobalRedirectTest.php, line 97

Class

GlobalRedirectTest
Global redirect test cases.

Namespace

Drupal\Tests\redirect\Functional

Code

protected function setUp() {
  parent::setUp();
  $this->config = $this
    ->config('redirect.settings');
  $this
    ->drupalCreateContentType([
    'type' => 'page',
    'name' => 'Page',
  ]);
  $this
    ->drupalCreateContentType([
    'type' => 'article',
    'name' => 'Article',
  ]);

  // Create a users for testing the access.
  $this->normalUser = $this
    ->drupalCreateUser([
    'access content',
    'create page content',
    'create url aliases',
    'access administration pages',
  ]);
  $this->adminUser = $this
    ->drupalCreateUser([
    'administer site configuration',
    'access administration pages',
    'administer languages',
    'administer content types',
    'administer content translation',
    'create page content',
    'edit own page content',
    'create content translations',
  ]);

  // Save the node.
  $this->node = $this
    ->drupalCreateNode([
    'type' => 'page',
    'title' => 'Test Page Node',
    'path' => [
      'alias' => '/test-node',
    ],
    'language' => Language::LANGCODE_NOT_SPECIFIED,
  ]);

  // Create an alias for the create story path - this is used in the
  // "redirect with permissions testing" test.
  $this
    ->createPathAlias('/admin/config/system/site-information', '/site-info');

  // Create a taxonomy term for the forum.
  $term = Term::create([
    'name' => 'Test Forum Term',
    'vid' => 'forums',
    'langcode' => Language::LANGCODE_NOT_SPECIFIED,
  ]);
  $term
    ->save();
  $this->forumTerm = $term;

  // Create another taxonomy vocabulary with a term.
  $vocab = Vocabulary::create([
    'name' => 'test vocab',
    'vid' => 'test-vocab',
    'langcode' => Language::LANGCODE_NOT_SPECIFIED,
  ]);
  $vocab
    ->save();
  $term = Term::create([
    'name' => 'Test Term',
    'vid' => $vocab
      ->id(),
    'langcode' => Language::LANGCODE_NOT_SPECIFIED,
    'path' => [
      'alias' => '/test-term',
    ],
  ]);
  $term
    ->save();
  $this->term = $term;
}