You are here

function GlobalRedirectTest::setUp in Global Redirect 8

Sets up a Drupal site for running functional and integration tests.

Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.

Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Overrides WebTestBase::setUp

File

src/Tests/GlobalRedirectTest.php, line 60
Global Redirect functionality tests

Class

GlobalRedirectTest
Global redirect test cases.

Namespace

Drupal\globalredirect\Tests

Code

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

  // Create a users for testing the access.
  $this->normalUser = $this
    ->drupalCreateUser(array(
    'access content',
    'create page content',
    'create url aliases',
    'access administration pages',
  ));
  $this->adminUser = $this
    ->drupalCreateUser(array(
    'administer site configuration',
    'access administration pages',
  ));

  // Save the node
  $this->node = $this
    ->drupalCreateNode(array(
    'type' => 'page',
    'title' => 'Test Page Node',
    'path' => array(
      '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.
  \Drupal::service('path.alias_storage')
    ->save('admin/config/system/site-information', 'site-info');

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

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