function RowEntityRenderersTest::assertTranslations
Same name in other branches
- 8.9.x core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php \Drupal\Tests\views\Kernel\Entity\RowEntityRenderersTest::assertTranslations()
- 10 core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php \Drupal\Tests\views\Kernel\Entity\RowEntityRenderersTest::assertTranslations()
- 11.x core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php \Drupal\Tests\views\Kernel\Entity\RowEntityRenderersTest::assertTranslations()
Checks that the view results match the expected values.
@internal
Parameters
string $display: Name of display to test with.
string $renderer_id: The id of the renderer to be tested.
array $expected: An array of expected title translation values, one for each result row.
string $message: (optional) A message to display with the assertion.
1 call to RowEntityRenderersTest::assertTranslations()
- RowEntityRenderersTest::checkLanguageRenderers in core/
modules/ views/ tests/ src/ Kernel/ Entity/ RowEntityRenderersTest.php - Checks that the language renderer configurations work as expected.
File
-
core/
modules/ views/ tests/ src/ Kernel/ Entity/ RowEntityRenderersTest.php, line 257
Class
- RowEntityRenderersTest
- Tests the entity row renderers.
Namespace
Drupal\Tests\views\Kernel\EntityCode
protected function assertTranslations(string $display, string $renderer_id, array $expected, string $message = '') : void {
$view = Views::getView('test_entity_row_renderers');
$view->storage
->invalidateCaches();
$view->setDisplay($display);
$view->getDisplay()
->setOption('rendering_language', $renderer_id);
$view->preview();
$result = FALSE;
foreach ($expected as $index => $expected_output) {
if (!empty($view->result[$index])) {
$build = $view->rowPlugin
->render($view->result[$index]);
$output = \Drupal::service('renderer')->renderRoot($build);
$result = strpos($output, $expected_output) !== FALSE;
if (!$result) {
break;
}
}
else {
$result = FALSE;
break;
}
}
$this->assertTrue($result, $message);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.