protected function ContentFullViewFiltersFieldsTest::setUp in Translation Views 8
Overrides ViewTestBase::setUp
File
- tests/
src/ Functional/ ContentFullViewFiltersFieldsTest.php, line 38
Class
- ContentFullViewFiltersFieldsTest
- Tests for fields, filters and sorting for content entity.
Namespace
Drupal\Tests\translation_views\FunctionalCode
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
$user = $this
->drupalCreateUser([
'administer site configuration',
'administer nodes',
'administer views',
'create article content',
'access content',
'edit any article content',
'administer content translation',
'translate any entity',
'create content translations',
'administer languages',
'administer content types',
]);
$this
->drupalLogin($user);
ViewTestData::createTestViews(get_class($this), [
'translation_views_test_views',
]);
$langcodes = [
'de',
'fr',
];
foreach ($langcodes as $langcode) {
ConfigurableLanguage::createFromLangcode($langcode)
->save();
}
// Enable translation for article.
$edit = [
'entity_types[node]' => 1,
'settings[node][article][translatable]' => 1,
'settings[node][article][settings][language][language_alterable]' => 1,
];
$this
->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
\Drupal::entityTypeManager()
->clearCachedDefinitions();
// Create a node in en (node1).
$edit = [
'title[0][value]' => '001_en_title_node1',
'langcode[0][value]' => 'en',
];
$this
->drupalPostForm('node/add/article', $edit, t('Save'));
// Create a translation in fr (node1).
$edit = [
'title[0][value]' => '002_fr_title_node1',
];
$this
->drupalPostForm('node/1/translations/add/en/fr', $edit, t('Save (this translation)'));
// Create a translation in de (node1).
$edit = [
'title[0][value]' => '003_de_title_node1',
];
$this
->drupalPostForm('node/1/translations/add/en/de', $edit, t('Save (this translation)'));
// Create a node in de (node2).
$edit = [
'title[0][value]' => '004_de_title_node2',
'langcode[0][value]' => 'de',
];
$this
->drupalPostForm('node/add/article', $edit, t('Save'));
// Create a translation in fr (node2).
$edit = [
'title[0][value]' => '005_fr_title_node2',
];
$this
->drupalPostForm('node/2/translations/add/de/fr', $edit, t('Save (this translation)'));
}