function ContentTranslationContextualLinksTest::setUp

Same name in this branch
  1. 9 core/modules/content_translation/tests/src/FunctionalJavascript/ContentTranslationContextualLinksTest.php \Drupal\Tests\content_translation\FunctionalJavascript\ContentTranslationContextualLinksTest::setUp()
Same name and namespace in other branches
  1. 8.9.x core/modules/content_translation/tests/src/FunctionalJavascript/ContentTranslationContextualLinksTest.php \Drupal\Tests\content_translation\FunctionalJavascript\ContentTranslationContextualLinksTest::setUp()
  2. 8.9.x core/modules/content_translation/tests/src/Functional/ContentTranslationContextualLinksTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationContextualLinksTest::setUp()
  3. 10 core/modules/content_translation/tests/src/FunctionalJavascript/ContentTranslationContextualLinksTest.php \Drupal\Tests\content_translation\FunctionalJavascript\ContentTranslationContextualLinksTest::setUp()
  4. 10 core/modules/content_translation/tests/src/Functional/ContentTranslationContextualLinksTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationContextualLinksTest::setUp()
  5. 11.x core/modules/content_translation/tests/src/FunctionalJavascript/ContentTranslationContextualLinksTest.php \Drupal\Tests\content_translation\FunctionalJavascript\ContentTranslationContextualLinksTest::setUp()
  6. 11.x core/modules/content_translation/tests/src/Functional/ContentTranslationContextualLinksTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationContextualLinksTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/content_translation/tests/src/Functional/ContentTranslationContextualLinksTest.php, line 67

Class

ContentTranslationContextualLinksTest
Tests that contextual links are available for content translation.

Namespace

Drupal\Tests\content_translation\Functional

Code

protected function setUp() : void {
    parent::setUp();
    // Set up an additional language.
    $this->langcodes = [
        \Drupal::languageManager()->getDefaultLanguage()
            ->getId(),
        'es',
    ];
    ConfigurableLanguage::createFromLangcode('es')->save();
    // Create a content type.
    $this->bundle = $this->randomMachineName();
    $this->contentType = $this->drupalCreateContentType([
        'type' => $this->bundle,
    ]);
    // Add a field to the content type. The field is not yet translatable.
    FieldStorageConfig::create([
        'field_name' => 'field_test_text',
        'entity_type' => 'node',
        'type' => 'text',
        'cardinality' => 1,
    ])->save();
    FieldConfig::create([
        'entity_type' => 'node',
        'field_name' => 'field_test_text',
        'bundle' => $this->bundle,
        'label' => 'Test text-field',
    ])
        ->save();
    $this->container
        ->get('entity_display.repository')
        ->getFormDisplay('node', $this->bundle)
        ->setComponent('field_test_text', [
        'type' => 'text_textfield',
        'weight' => 0,
    ])
        ->save();
    // Create a translator user.
    $permissions = [
        'access contextual links',
        'administer nodes',
        "edit any {$this->bundle} content",
        'translate any entity',
    ];
    $this->translator = $this->drupalCreateUser($permissions);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.