public function NameAdminTest::assertRow 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.
2 calls to NameAdminTest::assertRow()
- NameAdminTest::testAdminFormatSettings in tests/
src/ Functional/ NameAdminTest.php - Misc tests related to adding, updating and removing formats.
- NameAdminTest::testAdminListFormatSettings in tests/
src/ Functional/ NameAdminTest.php - Misc tests related to adding, updating and removing formats.
File
- tests/
src/ Functional/ NameAdminTest.php, line 318
Class
- NameAdminTest
- Tests for the admin settings and custom format page.
Namespace
Drupal\Tests\name\FunctionalCode
public function assertRow(array $row, array $row_template, $id) {
foreach ($row as $cell_code => $value) {
if (isset($row_template[$cell_code])) {
$xpath = str_replace('{row}', $id, $row_template[$cell_code]);
$elements = $this
->xpath($xpath);
// Check URLs with or without the ?destination= query parameter.
if (strpos($row_template[$cell_code], '/a/@href')) {
$results = isset($elements[0]) ? $elements[0]
->getHtml() : '';
$message = "Testing {$cell_code} on row {$id} using '{$xpath}' and expecting '" . Html::escape($value) . "', got '" . Html::escape($results) . "'.";
if ($results == $value || strpos($results, $value . '?destination=') === 0) {
$this
->pass($message);
}
else {
$this
->fail($message);
}
}
else {
$results = $this
->normalizeOutput($elements);
$message = "Testing {$cell_code} on row {$id} using '{$xpath}' and expecting '" . Html::escape($value) . "', got '" . Html::escape($results) . "'.";
$this
->assertEquals($results, $value, $message);
}
}
}
}