You are here

function NodeFieldFilterTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/Tests/Views/NodeFieldFilterTest.php \Drupal\node\Tests\Views\NodeFieldFilterTest::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 NodeTestBase::setUp

File

core/modules/node/src/Tests/Views/NodeFieldFilterTest.php, line 38
Contains \Drupal\node\Tests\Views\NodeFieldFilterTest.

Class

NodeFieldFilterTest
Tests node field filters with translations.

Namespace

Drupal\node\Tests\Views

Code

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

  // Create Page content type.
  if ($this->profile != 'standard') {
    $this
      ->drupalCreateContentType(array(
      'type' => 'page',
      'name' => 'Basic page',
    ));
  }

  // Add two new languages.
  ConfigurableLanguage::createFromLangcode('fr')
    ->save();
  ConfigurableLanguage::createFromLangcode('es')
    ->save();

  // Set up node titles.
  $this->nodeTitles = array(
    'en' => 'Food in Paris',
    'es' => 'Comida en Paris',
    'fr' => 'Nouriture en Paris',
  );

  // Create node with translations.
  $node = $this
    ->drupalCreateNode([
    'title' => $this->nodeTitles['en'],
    'langcode' => 'en',
    'type' => 'page',
    'body' => [
      [
        'value' => $this->nodeTitles['en'],
      ],
    ],
  ]);
  foreach (array(
    'es',
    'fr',
  ) as $langcode) {
    $translation = $node
      ->addTranslation($langcode, [
      'title' => $this->nodeTitles[$langcode],
    ]);
    $translation->body->value = $this->nodeTitles[$langcode];
  }
  $node
    ->save();
}