You are here

protected function FieldEntityLinkBaseTest::setUp in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Functional/Handler/FieldEntityLinkBaseTest.php \Drupal\Tests\views\Functional\Handler\FieldEntityLinkBaseTest::setUp()
  2. 9 core/modules/views/tests/src/Functional/Handler/FieldEntityLinkBaseTest.php \Drupal\Tests\views\Functional\Handler\FieldEntityLinkBaseTest::setUp()

File

core/modules/views/tests/src/Functional/Handler/FieldEntityLinkBaseTest.php, line 36

Class

FieldEntityLinkBaseTest
Tests the core Drupal\views\Plugin\views\field\LinkBase handler.

Namespace

Drupal\Tests\views\Functional\Handler

Code

protected function setUp($import_test_views = TRUE, $modules = [
  'views_test_config',
]) : void {
  parent::setUp($import_test_views, $modules);
  $this
    ->drupalCreateContentType([
    'type' => 'article',
    'name' => 'Article',
  ]);

  // Add languages and refresh the container so the entity type manager will
  // have fresh data.
  ConfigurableLanguage::createFromLangcode('hu')
    ->save();
  ConfigurableLanguage::createFromLangcode('es')
    ->save();
  $this
    ->rebuildContainer();

  // Create an English and Hungarian nodes and add a Spanish translation.
  foreach ([
    'en',
    'hu',
  ] as $langcode) {
    $entity = Node::create([
      'title' => $this
        ->randomMachineName(),
      'type' => 'article',
      'langcode' => $langcode,
    ]);
    $entity
      ->save();
    $translation = $entity
      ->addTranslation('es');
    $translation
      ->set('title', $entity
      ->getTitle() . ' in Spanish');
    $translation
      ->save();
  }
  $this
    ->drupalLogin($this->rootUser);
}