function NodeFieldFilterTest::setUp
Same name in other branches
- 8.9.x core/modules/node/tests/src/Functional/Views/NodeFieldFilterTest.php \Drupal\Tests\node\Functional\Views\NodeFieldFilterTest::setUp()
- 10 core/modules/node/tests/src/Functional/Views/NodeFieldFilterTest.php \Drupal\Tests\node\Functional\Views\NodeFieldFilterTest::setUp()
- 11.x core/modules/node/tests/src/Functional/Views/NodeFieldFilterTest.php \Drupal\Tests\node\Functional\Views\NodeFieldFilterTest::setUp()
Overrides NodeTestBase::setUp
File
-
core/
modules/ node/ tests/ src/ Functional/ Views/ NodeFieldFilterTest.php, line 41
Class
- NodeFieldFilterTest
- Tests node field filters with translations.
Namespace
Drupal\Tests\node\Functional\ViewsCode
protected function setUp($import_test_views = TRUE, $modules = [
'node_test_views',
]) : void {
parent::setUp($import_test_views, $modules);
// Create Page content type.
if ($this->profile != 'standard') {
$this->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
]);
}
// Add two new languages.
ConfigurableLanguage::createFromLangcode('fr')->save();
ConfigurableLanguage::createFromLangcode('es')->save();
// Set up node titles.
$this->nodeTitles = [
'en' => 'Food in Paris',
'es' => 'Comida en Paris',
'fr' => 'Nourriture en Paris',
];
// Create node with translations.
$node = $this->drupalCreateNode([
'title' => $this->nodeTitles['en'],
'langcode' => 'en',
'type' => 'page',
'body' => [
[
'value' => $this->nodeTitles['en'],
],
],
]);
foreach ([
'es',
'fr',
] as $langcode) {
$translation = $node->addTranslation($langcode, [
'title' => $this->nodeTitles[$langcode],
]);
$translation->body->value = $this->nodeTitles[$langcode];
}
$node->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.