protected function RowEntityRenderersTest::assertTranslations in Drupal 9
Same name and namespace in other branches
- 8 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.
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.
string $group: (optional) The group this message is in.
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 247
Class
- RowEntityRenderersTest
- Tests the entity row renderers.
Namespace
Drupal\Tests\views\Kernel\EntityCode
protected function assertTranslations($display, $renderer_id, array $expected, $message = '', $group = 'Other') {
$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, $group);
}