You are here

public function FieldUITest::testFieldUI in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views_ui/src/Tests/FieldUITest.php \Drupal\views_ui\Tests\FieldUITest::testFieldUI()

Tests the UI of field handlers.

File

core/modules/views_ui/src/Tests/FieldUITest.php, line 30
Contains \Drupal\views_ui\Tests\FieldUITest.

Class

FieldUITest
Tests the UI of field handlers.

Namespace

Drupal\views_ui\Tests

Code

public function testFieldUI() {

  // Ensure the field is not marked as hidden on the first run.
  $this
    ->drupalGet('admin/structure/views/view/test_view/edit');
  $this
    ->assertText('Views test: Name');
  $this
    ->assertNoText('Views test: Name [' . t('hidden') . ']');

  // Hides the field and check whether the hidden label is appended.
  $edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/name';
  $this
    ->drupalPostForm($edit_handler_url, array(
    'options[exclude]' => TRUE,
  ), t('Apply'));
  $this
    ->assertText('Views test: Name [' . t('hidden') . ']');

  // Ensure that the expected tokens appear in the UI.
  $edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/age';
  $this
    ->drupalGet($edit_handler_url);
  $result = $this
    ->xpath('//details[@id="edit-options-alter-help"]/div[@class="details-wrapper"]/div[@class="item-list"]/ul/li');
  $this
    ->assertEqual((string) $result[0], '{{ age }} == Age');
  $edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/id';
  $this
    ->drupalGet($edit_handler_url);
  $result = $this
    ->xpath('//details[@id="edit-options-alter-help"]/div[@class="details-wrapper"]/div[@class="item-list"]/ul/li');
  $this
    ->assertEqual((string) $result[0], '{{ age }} == Age');
  $this
    ->assertEqual((string) $result[1], '{{ id }} == ID');
  $edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/name';
  $this
    ->drupalGet($edit_handler_url);
  $result = $this
    ->xpath('//details[@id="edit-options-alter-help"]/div[@class="details-wrapper"]/div[@class="item-list"]/ul/li');
  $this
    ->assertEqual((string) $result[0], '{{ age }} == Age');
  $this
    ->assertEqual((string) $result[1], '{{ id }} == ID');
  $this
    ->assertEqual((string) $result[2], '{{ name }} == Name');
  $result = $this
    ->xpath('//details[@id="edit-options-more"]');
  $this
    ->assertEqual(empty($result), true, "Container 'more' is empty and should not be displayed.");
}