public function TranslationTest::setUp in Feeds 8.3
Overrides FeedsKernelTestBase::setUp
File
- tests/
src/ Kernel/ Feeds/ Target/ TranslationTest.php, line 62
Class
- TranslationTest
- Test for the entity field translation.
Namespace
Drupal\Tests\feeds\Kernel\Feeds\TargetCode
public function setUp() {
parent::setUp();
// Add languages.
foreach ($this->feedsTranslationLanguages as $langcode) {
$language = $this->container
->get('entity_type.manager')
->getStorage('configurable_language')
->create([
'id' => $langcode,
]);
$language
->save();
}
// Set article bundle to be translatable.
$this->container
->get('content_translation.manager')
->setEnabled('node', 'article', TRUE);
// Create a text field.
$this
->createFieldWithStorage('field_alpha');
// Install taxonomy tables and add a vocabulary.
$this->vocabulary = $this
->installTaxonomyModuleWithVocabulary();
// And set it as translatable.
$this->container
->get('content_translation.manager')
->setEnabled('taxonomy_term', $this->vocabulary
->id(), TRUE);
// Add a term reference field to the article bundle.
$this
->createFieldWithStorage('field_tags', [
'entity_type' => 'node',
'bundle' => 'article',
'type' => 'entity_reference',
'storage' => [
'settings' => [
'target_type' => 'taxonomy_term',
],
],
'field' => [
'settings' => [
'handler' => 'default',
'handler_settings' => [
// Restrict selection of terms to a single vocabulary.
'target_bundles' => [
$this->vocabulary
->id() => $this->vocabulary
->id(),
],
],
],
],
]);
// Create feed type.
$this->feedType = $this
->createFeedTypeForCsv([
'guid' => 'guid',
'title_es' => 'title_es',
'title_nl' => 'title_nl',
'body_es' => 'body_es',
'body_nl' => 'body_nl',
'terms_es' => 'terms_es',
'terms_nl' => 'terms_nl',
]);
}