public function AreaTest::testUI

Tests the generic UI of a area handler.

File

drupal/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTest.php, line 63
Definition of Drupal\views\Tests\Handler\AreaTest.

Class

AreaTest
Tests the abstract area handler.

Namespace

Drupal\views\Tests\Handler

Code

public function testUI() {
  $admin_user = $this
    ->drupalCreateUser(array(
    'administer views',
    'administer site configuration',
  ));
  $this
    ->drupalLogin($admin_user);
  $types = array(
    'header',
    'footer',
    'empty',
  );
  $labels = array();
  foreach ($types as $type) {
    $edit_path = 'admin/structure/views/nojs/config-item/test_example_area/default/' . $type . '/test_example';

    // First setup an empty label.
    $this
      ->drupalPost($edit_path, array(), t('Apply'));
    $this
      ->assertText('Test Example area');

    // Then setup a no empty label.
    $labels[$type] = $this
      ->randomName();
    $this
      ->drupalPost($edit_path, array(
      'options[admin_label]' => $labels[$type],
    ), t('Apply'));

    // Make sure that the new label appears on the site.
    $this
      ->assertText($labels[$type]);

    // Test that the settings (empty/admin_label) are accessible.
    $this
      ->drupalGet($edit_path);
    $this
      ->assertField('options[admin_label]');
    if ($type !== 'empty') {
      $this
        ->assertField('options[empty]');
    }
  }
}