You are here

protected function SettingsTest::setUp in Acquia Lift Connector 8

Same name and namespace in other branches
  1. 8.3 src/Tests/SettingsTest.php \Drupal\acquia_lift\Tests\SettingsTest::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

File

src/Tests/SettingsTest.php, line 32
Contains \Drupal\acquia_lift\Tests\SettingsTest.

Class

SettingsTest
Test Acquia Lift Settings.

Namespace

Drupal\acquia_lift\Tests

Code

protected function setUp() {
  parent::setUp();
  $permissions = [
    'access administration pages',
    'administer acquia lift',
    'administer content types',
    'administer modules',
    'administer site configuration',
  ];

  // Create article content type.
  $this
    ->drupalCreateContentType([
    'type' => 'article',
    'name' => 'Article',
  ]);

  // Create a Node.
  $this
    ->drupalCreateNode([
    'nid' => 90210,
    'type' => 'article',
    'body' => [
      [
        'value' => $this
          ->randomMachineName(32),
        'format' => 'full_html',
      ],
    ],
  ]);

  // Create two vocabularies.
  $vocabulary1 = $this
    ->createVocabulary();
  $vocabulary2 = $this
    ->createVocabulary();
  $term_v1_t1 = $this
    ->createTerm($vocabulary1);
  $term_v1_t2 = $this
    ->createTerm($vocabulary1);
  $term_v2_t1 = $this
    ->createTerm($vocabulary2);
  $term_v2_t2 = $this
    ->createTerm($vocabulary2);
  $term_v2_t3 = $this
    ->createTerm($vocabulary2);
  $field_country = $this
    ->createFieldWithStorage('field_country', 'node', 'article', [
    $vocabulary1
      ->id() => $vocabulary1
      ->id(),
  ], [
    'target_type' => 'taxonomy_term',
  ], 'entity_reference');
  $field_people = $this
    ->createFieldWithStorage('field_people', 'node', 'article', [
    $vocabulary2
      ->id() => $vocabulary2
      ->id(),
  ], [
    'target_type' => 'taxonomy_term',
  ], 'entity_reference');
  $field_tags = $this
    ->createFieldWithStorage('field_tags', 'node', 'article', [
    $vocabulary2
      ->id() => $vocabulary2
      ->id(),
  ], [
    'target_type' => 'taxonomy_term',
  ], 'entity_reference');

  // User to set up acquia_lift.
  $this->admin_user = $this
    ->drupalCreateUser($permissions);
  $this
    ->drupalLogin($this->admin_user);
}