public function StyleTableTest::testAccessibilitySettings in Drupal 8
Same name and namespace in other branches
- 9 core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php \Drupal\Tests\views\Functional\Plugin\StyleTableTest::testAccessibilitySettings()
Test table caption/summary/description.
File
- core/
modules/ views/ tests/ src/ Functional/ Plugin/ StyleTableTest.php, line 41
Class
- StyleTableTest
- Tests the table style views plugin.
Namespace
Drupal\Tests\views\Functional\PluginCode
public function testAccessibilitySettings() {
$this
->drupalGet('test-table');
$result = $this
->xpath('//caption/child::text()');
$this
->assertNotEmpty($result, 'The caption appears on the table.');
$this
->assertEqual(trim($result[0]
->getText()), 'caption-text');
$result = $this
->xpath('//summary/child::text()');
$this
->assertNotEmpty($result, 'The summary appears on the table.');
$this
->assertEqual(trim($result[0]
->getText()), 'summary-text');
// Check that the summary has the right accessibility settings.
$summary = $this
->xpath('//summary')[0];
$this
->assertTrue($summary
->hasAttribute('role'));
$this
->assertTrue($summary
->hasAttribute('aria-expanded'));
$result = $this
->xpath('//caption/details/child::text()[normalize-space()]');
$this
->assertNotEmpty($result, 'The table description appears on the table.');
$this
->assertEqual(trim($result[0]
->getText()), 'description-text');
// Remove the caption and ensure the caption is not displayed anymore.
$view = View::load('test_table');
$display =& $view
->getDisplay('default');
$display['display_options']['style']['options']['caption'] = '';
$view
->save();
$this
->drupalGet('test-table');
$result = $this
->xpath('//caption/child::text()');
$this
->assertEmpty(trim($result[0]
->getText()), '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/child::text()');
$this
->assertEmpty($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/child::text()[normalize-space()]');
$this
->assertEmpty($result, 'Ensure that the description disappears.');
}