function ConfigTranslationListUiTest::doFieldListTest

Same name in other branches
  1. 9 core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationListUiTest::doFieldListTest()
  2. 8.9.x core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationListUiTest::doFieldListTest()
  3. 11.x core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationListUiTest::doFieldListTest()

Tests the field listing for the translate operation.

1 call to ConfigTranslationListUiTest::doFieldListTest()
ConfigTranslationListUiTest::testTranslateOperationInListUi in core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php
Tests if translate link is added to operations in all configuration lists.

File

core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php, line 405

Class

ConfigTranslationListUiTest
Visit all lists.

Namespace

Drupal\Tests\config_translation\Functional

Code

public function doFieldListTest() {
    // Create a base content type.
    $content_type = $this->drupalCreateContentType([
        'type' => $this->randomMachineName(16),
        'name' => $this->randomMachineName(),
    ]);
    // Create a block content type.
    $block_content_type = BlockContentType::create([
        'id' => 'basic',
        'label' => 'Basic',
        'revision' => FALSE,
    ]);
    $block_content_type->save();
    $field = FieldConfig::create([
        // The field storage is guaranteed to exist because it is supplied by the
        // block_content module.
'field_storage' => FieldStorageConfig::loadByName('block_content', 'body'),
        'bundle' => $block_content_type->id(),
        'label' => 'Body',
        'settings' => [
            'display_summary' => FALSE,
            'allowed_formats' => [],
        ],
    ]);
    $field->save();
    // Look at a few fields on a few entity types.
    $pages = [
        [
            'list' => 'admin/structure/types/manage/' . $content_type->id() . '/fields',
            'field' => 'node.' . $content_type->id() . '.body',
        ],
        [
            'list' => 'admin/structure/block-content/manage/basic/fields',
            'field' => 'block_content.basic.body',
        ],
    ];
    foreach ($pages as $values) {
        // Get fields listing.
        $this->drupalGet($values['list']);
        $translate_link = $values['list'] . '/' . $values['field'] . '/translate';
        // Test if the link to translate the field is on the page.
        $this->assertSession()
            ->linkByHrefExists($translate_link);
        // Test if the link to translate actually goes to the translate page.
        $this->drupalGet($translate_link);
        $this->assertSession()
            ->responseContains('<th>Language</th>');
    }
}

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