LinkFieldUITest.php 1.77 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 12 13 14
use Drupal\simpletest\WebTestBase;

/**
 * Tests link field UI functionality.
15 16
 *
 * @group link
17 18 19 20 21 22 23 24 25 26
 */
class LinkFieldUITest extends WebTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = array('node', 'link', 'field_ui');

27
  protected function setUp() {
28 29
    parent::setUp();

30
    $this->web_user = $this->drupalCreateUser(array('administer content types', 'administer node fields', 'administer node display'));
31 32 33 34 35 36 37 38 39 40 41 42
    $this->drupalLogin($this->web_user);
  }

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

    // Add a link field to the newly-created type.
43
    $label = $this->randomMachineName();
44
    $field_name = Unicode::strtolower($label);
45 46 47 48 49
    $edit = array(
      'fields[_add_new_field][label]' => $label,
      'fields[_add_new_field][field_name]' => $field_name,
      'fields[_add_new_field][type]' => 'link',
    );
50
    $this->drupalPostForm("$type_path/fields", $edit, t('Save'));
51
    // Proceed to the Edit (field settings) page.
52
    $this->drupalPostForm(NULL, array(), t('Save field settings'));
53
    // Proceed to the Manage fields overview page.
54
    $this->drupalPostForm(NULL, array(), t('Save settings'));
55 56 57 58 59 60 61 62 63

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

}