public function DisplayFeedTranslationTest::testFeedFieldOutput in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Functional/Plugin/DisplayFeedTranslationTest.php \Drupal\Tests\views\Functional\Plugin\DisplayFeedTranslationTest::testFeedFieldOutput()
- 10 core/modules/views/tests/src/Functional/Plugin/DisplayFeedTranslationTest.php \Drupal\Tests\views\Functional\Plugin\DisplayFeedTranslationTest::testFeedFieldOutput()
Tests the rendered output for fields display with multiple translations.
File
- core/
modules/ views/ tests/ src/ Functional/ Plugin/ DisplayFeedTranslationTest.php, line 90
Class
- DisplayFeedTranslationTest
- Tests the feed display plugin with translated content.
Namespace
Drupal\Tests\views\Functional\PluginCode
public function testFeedFieldOutput() {
$node = $this
->drupalCreateNode([
'type' => 'page',
'title' => 'en',
'body' => [
0 => [
'value' => 'Something in English.',
'format' => filter_default_format(),
],
],
'langcode' => 'en',
]);
$es_translation = $node
->addTranslation('es');
$es_translation
->set('title', 'es');
$es_translation
->set('body', [
[
'value' => 'Algo en Español',
],
]);
$es_translation
->save();
$pt_br_translation = $node
->addTranslation('pt-br');
$pt_br_translation
->set('title', 'pt-br');
$pt_br_translation
->set('body', [
[
'value' => 'Algo em Português',
],
]);
$pt_br_translation
->save();
// First, check everything with raw node paths (e.g. node/1).
$this
->checkFeedResults('raw-node-path', $node);
// Now, create path aliases for each translation.
$node_path = '/node/' . $node
->id();
$this
->createPathAlias($node_path, "{$node_path}/en-alias");
$this
->createPathAlias($node_path, "{$node_path}/es-alias", 'es');
$this
->createPathAlias($node_path, "{$node_path}/pt-br-alias", 'pt-br');
// Save the node again, to clear the cache on the feed.
$node
->save();
// Assert that all the results are correct using path aliases.
$this
->checkFeedResults('path-alias', $node);
}