function TableDragTest::testRowWeightSwitch

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php \Drupal\FunctionalJavascriptTests\TableDrag\TableDragTest::testRowWeightSwitch()
  2. 8.9.x core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php \Drupal\FunctionalJavascriptTests\TableDrag\TableDragTest::testRowWeightSwitch()
  3. 11.x core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php \Drupal\FunctionalJavascriptTests\TableDrag\TableDragTest::testRowWeightSwitch()

Tests row weight switch.

File

core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php, line 66

Class

TableDragTest
Tests draggable table.

Namespace

Drupal\FunctionalJavascriptTests\TableDrag

Code

public function testRowWeightSwitch() : void {
    $this->state
        ->set('tabledrag_test_table', array_flip(range(1, 3)));
    $this->drupalGet('tabledrag_test');
    $session = $this->getSession();
    $page = $session->getPage();
    $weight_select1 = $page->findField("table[1][weight]");
    $weight_select2 = $page->findField("table[2][weight]");
    $weight_select3 = $page->findField("table[3][weight]");
    // Check that rows weight selects are hidden.
    $this->assertFalse($weight_select1->isVisible());
    $this->assertFalse($weight_select2->isVisible());
    $this->assertFalse($weight_select3->isVisible());
    // Toggle row weight selects as visible.
    $this->findWeightsToggle('Show row weights')
        ->click();
    // Check that rows weight selects are visible.
    $this->assertTrue($weight_select1->isVisible());
    $this->assertTrue($weight_select2->isVisible());
    $this->assertTrue($weight_select3->isVisible());
    // Toggle row weight selects back to hidden.
    $this->findWeightsToggle('Hide row weights')
        ->click();
    // Check that rows weight selects are hidden again.
    $this->assertFalse($weight_select1->isVisible());
    $this->assertFalse($weight_select2->isVisible());
    $this->assertFalse($weight_select3->isVisible());
}

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