LinkFieldUITest.php 1.39 KB
Newer Older
1 2 3 4 5 6 7 8 9
<?php

/**
 * @file
 * Contains Drupal\link\Tests\LinkFieldUITest.
 */

namespace Drupal\link\Tests;

10
use Drupal\Component\Utility\Unicode;
11
use Drupal\field_ui\Tests\FieldUiTestTrait;
12 13 14 15
use Drupal\simpletest\WebTestBase;

/**
 * Tests link field UI functionality.
16 17
 *
 * @group link
18 19 20
 */
class LinkFieldUITest extends WebTestBase {

21 22
  use FieldUiTestTrait;

23 24 25 26 27
  /**
   * Modules to enable.
   *
   * @var array
   */
28
  public static $modules = ['node', 'link', 'field_ui'];
29

30
  protected function setUp() {
31 32
    parent::setUp();

33
    $this->drupalLogin($this->drupalCreateUser(['administer content types', 'administer node fields', 'administer node display']));
34 35 36 37 38 39 40 41
  }

  /**
   * Tests that link field UI functionality does not generate warnings.
   */
  function testFieldUI() {
    // Add a content type.
    $type = $this->drupalCreateContentType();
42
    $type_path = 'admin/structure/types/manage/' . $type->id();
43 44

    // Add a link field to the newly-created type.
45
    $label = $this->randomMachineName();
46
    $field_name = Unicode::strtolower($label);
47
    $this->fieldUIAddNewField($type_path, $field_name, $label, 'link');
48 49 50 51 52 53 54 55 56

    // Load the formatter page to check that the settings summary does not
    // generate warnings.
    // @todo Mess with the formatter settings a bit here.
    $this->drupalGet("$type_path/display");
    $this->assertText(t('Link text trimmed to @limit characters', array('@limit' => 80)));
  }

}