LinkFieldUITest.php 1.48 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', 'block'];
29

30 31 32
  /**
   * {@inheritdoc}
   */
33
  protected function setUp() {
34 35
    parent::setUp();

36
    $this->drupalLogin($this->drupalCreateUser(['administer content types', 'administer node fields', 'administer node display']));
37
    $this->drupalPlaceBlock('system_breadcrumb_block');
38 39 40 41 42 43 44 45
  }

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

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

    // 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)));
  }

}