You are here

public function TranslationTest::testAutocreatedTermDefaultLanguage in Feeds 8.3

Tests importing auto-created terms when no language is configured for it.

File

tests/src/Kernel/Feeds/Target/TranslationTest.php, line 425

Class

TranslationTest
Test for the entity field translation.

Namespace

Drupal\Tests\feeds\Kernel\Feeds\Target

Code

public function testAutocreatedTermDefaultLanguage() {
  $this->feedType
    ->addMapping([
    'target' => 'field_tags',
    'map' => [
      'target_id' => 'terms',
    ],
    'settings' => [
      'reference_by' => 'name',
      'language' => NULL,
      'autocreate' => 1,
    ],
  ]);
  $this->feedType
    ->save();

  // Import Spanish content.
  $this
    ->importContent($this
    ->resourcesPath() . '/csv/translation/content_es.csv');
  $this
    ->assertNodeCount(1);

  // Assert that the term was created in the default language.
  $default_langcode = $this->container
    ->get('language.default')
    ->get()
    ->getId();
  $term = Term::load(1);
  $this
    ->assertEquals('Termino de taxonomía', $term->name->value);
  $this
    ->assertEquals($default_langcode, $term->langcode->value);
}