You are here

public function StyleTableTest::testAccessibilitySettings in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/Plugin/StyleTableTest.php \Drupal\views\Tests\Plugin\StyleTableTest::testAccessibilitySettings()

Test table caption/summary/description.

File

core/modules/views/src/Tests/Plugin/StyleTableTest.php, line 36
Contains \Drupal\views\Tests\Plugin\StyleTableTest.

Class

StyleTableTest
Tests the table style views plugin.

Namespace

Drupal\views\Tests\Plugin

Code

public function testAccessibilitySettings() {
  $this
    ->drupalGet('test-table');
  $result = $this
    ->xpath('//caption');
  $this
    ->assertTrue(count($result), 'The caption appears on the table.');
  $this
    ->assertEqual(trim((string) $result[0]), 'caption-text');
  $result = $this
    ->xpath('//summary');
  $this
    ->assertTrue(count($result), 'The summary appears on the table.');
  $this
    ->assertEqual(trim((string) $result[0]), 'summary-text');
  $result = $this
    ->xpath('//caption/details');
  $this
    ->assertTrue(count($result), 'The table description appears on the table.');
  $this
    ->assertEqual(trim((string) $result[0]), 'description-text');

  // Remove the caption and ensure the caption is not displayed anymore.
  $view = entity_load('view', 'test_table');
  $display =& $view
    ->getDisplay('default');
  $display['display_options']['style']['options']['caption'] = '';
  $view
    ->save();
  $this
    ->drupalGet('test-table');
  $result = $this
    ->xpath('//caption');
  $this
    ->assertFalse(trim((string) $result[0]), 'Ensure that the caption disappears.');

  // Remove the table summary.
  $display =& $view
    ->getDisplay('default');
  $display['display_options']['style']['options']['summary'] = '';
  $view
    ->save();
  $this
    ->drupalGet('test-table');
  $result = $this
    ->xpath('//summary');
  $this
    ->assertFalse(count($result), 'Ensure that the summary disappears.');

  // Remove the table description.
  $display =& $view
    ->getDisplay('default');
  $display['display_options']['style']['options']['description'] = '';
  $view
    ->save();
  $this
    ->drupalGet('test-table');
  $result = $this
    ->xpath('//caption/details');
  $this
    ->assertFalse(count($result), 'Ensure that the description disappears.');
}