You are here

public function ConfigTranslationListUiTest::doFieldListTest in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php \Drupal\config_translation\Tests\ConfigTranslationListUiTest::doFieldListTest()

Tests the field listing for the translate operation.

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

File

core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php, line 386
Contains \Drupal\config_translation\Tests\ConfigTranslationListUiTest.

Class

ConfigTranslationListUiTest
Visit all lists.

Namespace

Drupal\config_translation\Tests

Code

public function doFieldListTest() {

  // Create a base content type.
  $content_type = $this
    ->drupalCreateContentType(array(
    'type' => Unicode::strtolower($this
      ->randomMachineName(16)),
    'name' => $this
      ->randomMachineName(),
  ));

  // Create a block content type.
  $block_content_type = entity_create('block_content_type', array(
    'id' => 'basic',
    'label' => 'Basic',
    'revision' => FALSE,
  ));
  $block_content_type
    ->save();
  $field = entity_create('field_config', array(
    // 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' => array(
      'display_summary' => FALSE,
    ),
  ));
  $field
    ->save();

  // Look at a few fields on a few entity types.
  $pages = array(
    array(
      'list' => 'admin/structure/types/manage/' . $content_type
        ->id() . '/fields',
      'field' => 'node.' . $content_type
        ->id() . '.body',
    ),
    array(
      'list' => 'admin/structure/block/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
      ->assertLinkByHref($translate_link);

    // Test if the link to translate actually goes to the translate page.
    $this
      ->drupalGet($translate_link);
    $this
      ->assertRaw('<th>' . t('Language') . '</th>');
  }
}