function FieldUiTestBase::setUp

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

Generates a random database prefix and installs Drupal with the specified installation profile in Drupal\simpletest\WebTestBase::$profile into the prefixed database. Afterwards, installs any additional modules specified by the test.

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.

Parameters

...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.

Overrides WebTestBase::setUp

See also

Drupal\simpletest\WebTestBase::prepareDatabasePrefix()

Drupal\simpletest\WebTestBase::changeDatabasePrefix()

Drupal\simpletest\WebTestBase::prepareEnvironment()

1 call to FieldUiTestBase::setUp()
ManageFieldsTest::setUp in drupal/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php
Sets up a Drupal site for running functional and integration tests.
1 method overrides FieldUiTestBase::setUp()
ManageFieldsTest::setUp in drupal/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php
Sets up a Drupal site for running functional and integration tests.

File

drupal/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php, line 24
Definition of Drupal\field_ui\Tests\FieldUiTestBase.

Class

FieldUiTestBase
Provides common functionality for the Field UI test classes.

Namespace

Drupal\field_ui\Tests

Code

function setUp() {
  parent::setUp();

  // Create test user.
  $admin_user = $this
    ->drupalCreateUser(array(
    'access content',
    'administer content types',
    'administer taxonomy',
    'administer users',
    'bypass node access',
  ));
  $this
    ->drupalLogin($admin_user);

  // Create content type, with underscores.
  $type_name = strtolower($this
    ->randomName(8)) . '_test';
  $type = $this
    ->drupalCreateContentType(array(
    'name' => $type_name,
    'type' => $type_name,
  ));
  $this->type = $type->type;

  // Create a default vocabulary.
  $vocabulary = entity_create('taxonomy_vocabulary', array(
    'name' => $this
      ->randomName(),
    'description' => $this
      ->randomName(),
    'machine_name' => drupal_strtolower($this
      ->randomName()),
    'langcode' => LANGUAGE_NOT_SPECIFIED,
    'help' => '',
    'nodes' => array(
      'article' => 'article',
    ),
    'weight' => mt_rand(0, 10),
  ));
  taxonomy_vocabulary_save($vocabulary);
  $this->vocabulary = $vocabulary->machine_name;
}