function ElementsTableSelectTest::testTableSelectColSpan

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php \Drupal\Tests\system\Functional\Form\ElementsTableSelectTest::testTableSelectColSpan()
  2. 8.9.x core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php \Drupal\Tests\system\Functional\Form\ElementsTableSelectTest::testTableSelectColSpan()
  3. 11.x core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php \Drupal\Tests\system\Functional\Form\ElementsTableSelectTest::testTableSelectColSpan()

Tests the display when #colspan is set.

File

core/modules/system/tests/src/Functional/Form/ElementsTableSelectTest.php, line 66

Class

ElementsTableSelectTest
Tests the tableselect form element for expected behavior.

Namespace

Drupal\Tests\system\Functional\Form

Code

public function testTableSelectColSpan() : void {
  $this->drupalGet('form_test/tableselect/colspan');
  // Verify presence of column three and absence of column four.
  $this->assertSession()
    ->pageTextContains('Three');
  $this->assertSession()
    ->pageTextNotContains('Four');
  // There should be three labeled column headers and 1 for the input.
  $this->assertSession()
    ->elementsCount('xpath', '//thead/tr/th', 4);
  // The first two body rows should each have 5 table cells: One for the
  // radio, one cell in the first column, one cell in the second column,
  // and two cells in the third column which has colspan 2.
  for ($i = 0; $i <= 1; $i++) {
    $this->assertSession()
      ->elementsCount('xpath', '//tbody/tr[' . ($i + 1) . ']/td', 5);
  }
  // The third row should have 3 cells, one for the radio, one spanning the
  // first and second column, and a third in column 3 (which has colspan 3).
  $this->assertSession()
    ->elementsCount('xpath', '//tbody/tr[3]/td', 3);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.