You are here

public function NameAdminTest::assertRowContains in Name Field 8

Helper function to test a table cell via its expected value.

Parameters

array $row: Table rows to test.

array $row_template: The parameters used for each row test.

int $id: The row ID.

1 call to NameAdminTest::assertRowContains()
NameAdminTest::testAdminListFormatSettings in tests/src/Functional/NameAdminTest.php
Misc tests related to adding, updating and removing formats.

File

tests/src/Functional/NameAdminTest.php, line 354

Class

NameAdminTest
Tests for the admin settings and custom format page.

Namespace

Drupal\Tests\name\Functional

Code

public function assertRowContains(array $row, array $row_template, $id) {
  foreach ($row as $cell_code => $values) {
    if (isset($row_template[$cell_code])) {
      $xpath = str_replace('{row}', $id, $row_template[$cell_code]);
      $raw_xpath = $this
        ->xpath($xpath);
      $results = $this
        ->normalizeOutput($raw_xpath);
      $values = (array) $values;
      foreach ($values as $value) {
        $message = "{$cell_code} [{$id}] '{$xpath}': testing '{$value}'; got '{$results}'.";
        $this
          ->assertTrue(strpos($results, $value) !== FALSE, $message);
      }
    }
  }
}