You are here

protected function ShortcutTestBase::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/shortcut/src/Tests/ShortcutTestBase.php \Drupal\shortcut\Tests\ShortcutTestBase::setUp()

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

2 calls to ShortcutTestBase::setUp()
ShortcutLinksTest::setUp in core/modules/shortcut/src/Tests/ShortcutLinksTest.php
Sets up a Drupal site for running functional and integration tests.
ShortcutSetsTest::setUp in core/modules/shortcut/src/Tests/ShortcutSetsTest.php
Sets up a Drupal site for running functional and integration tests.
2 methods override ShortcutTestBase::setUp()
ShortcutLinksTest::setUp in core/modules/shortcut/src/Tests/ShortcutLinksTest.php
Sets up a Drupal site for running functional and integration tests.
ShortcutSetsTest::setUp in core/modules/shortcut/src/Tests/ShortcutSetsTest.php
Sets up a Drupal site for running functional and integration tests.

File

core/modules/shortcut/src/Tests/ShortcutTestBase.php, line 55
Contains \Drupal\shortcut\Tests\ShortcutTestBase.

Class

ShortcutTestBase
Defines base class for shortcut test cases.

Namespace

Drupal\shortcut\Tests

Code

protected function setUp() {
  parent::setUp();
  if ($this->profile != 'standard') {

    // Create Basic page and Article node types.
    $this
      ->drupalCreateContentType(array(
      'type' => 'page',
      'name' => 'Basic page',
    ));
    $this
      ->drupalCreateContentType(array(
      'type' => 'article',
      'name' => 'Article',
    ));

    // Populate the default shortcut set.
    $shortcut = Shortcut::create(array(
      'shortcut_set' => 'default',
      'title' => t('Add content'),
      'weight' => -20,
      'link' => array(
        'uri' => 'internal:/node/add',
      ),
    ));
    $shortcut
      ->save();
    $shortcut = Shortcut::create(array(
      'shortcut_set' => 'default',
      'title' => t('All content'),
      'weight' => -19,
      'link' => array(
        'uri' => 'internal:/admin/content',
      ),
    ));
    $shortcut
      ->save();
  }

  // Create users.
  $this->adminUser = $this
    ->drupalCreateUser(array(
    'access toolbar',
    'administer shortcuts',
    'view the administration theme',
    'create article content',
    'create page content',
    'access content overview',
    'administer users',
    'link to any page',
    'edit any article content',
  ));
  $this->shortcutUser = $this
    ->drupalCreateUser(array(
    'customize shortcut links',
    'switch shortcut sets',
    'access shortcuts',
    'access content',
  ));

  // Create a node.
  $this->node = $this
    ->drupalCreateNode(array(
    'type' => 'article',
  ));

  // Log in as admin and grab the default shortcut set.
  $this
    ->drupalLogin($this->adminUser);
  $this->set = ShortcutSet::load('default');
  \Drupal::entityManager()
    ->getStorage('shortcut_set')
    ->assignUser($this->set, $this->adminUser);
}