function TableDragTest::assertTableRow

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

Asserts the values of a draggable row.

@internal

Parameters

\Behat\Mink\Element\NodeElement $row: The row element to assert.

string $id: The expected value for the ID hidden input of the row.

int $weight: The expected weight of the row.

string $parent: The expected parent ID.

int $indentation: The expected indentation of the row.

bool|null $changed: Whether or not the row should have been marked as changed. NULL means that this assertion should be skipped.

bool $skip_missing: Whether assertions done on missing elements value may be skipped or not. Defaults to FALSE.

1 call to TableDragTest::assertTableRow()
TableDragTest::assertDraggableTable in core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php
Asserts the whole structure of the draggable test table.

File

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

Class

TableDragTest
Tests draggable table.

Namespace

Drupal\FunctionalJavascriptTests\TableDrag

Code

protected function assertTableRow(NodeElement $row, string $id, int $weight, string $parent = '', int $indentation = 0, ?bool $changed = FALSE, bool $skip_missing = FALSE) : void {
    // Assert that the row position is correct by checking that the id
    // corresponds.
    $id_name = "table[{$id}][id]";
    if (!$skip_missing || $row->find('hidden_field_selector', [
        'hidden_field',
        $id_name,
    ])) {
        $this->assertSession()
            ->hiddenFieldValueEquals($id_name, $id, $row);
    }
    $parent_name = "table[{$id}][parent]";
    if (!$skip_missing || $row->find('hidden_field_selector', [
        'hidden_field',
        $parent_name,
    ])) {
        $this->assertSession()
            ->hiddenFieldValueEquals($parent_name, $parent, $row);
    }
    $this->assertSession()
        ->fieldValueEquals("table[{$id}][weight]", $weight, $row);
    $this->assertSession()
        ->elementsCount('xpath', static::$indentationXpathSelector, $indentation, $row);
    // A row is marked as changed when the related markup is present.
    if ($changed !== NULL) {
        $this->assertSession()
            ->elementsCount('xpath', static::$tabledragChangedXpathSelector, (int) $changed, $row);
    }
}

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