You are here

public function TranslationTest::testValuesAreImportedAfterRemovingLanguage in Feeds 8.3

Tests if values are kept being imported after removing a language.

@todo In the D7 version, the values were getting imported as language neutral instead. Should we preserve that behavior?

File

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

Class

TranslationTest
Test for the entity field translation.

Namespace

Drupal\Tests\feeds\Kernel\Feeds\Target

Code

public function testValuesAreImportedAfterRemovingLanguage() {

  // Add mappings for Spanish.
  $this
    ->addMappings($this
    ->getMappingsInLanguage('es'));
  $this->feedType
    ->save();

  // Now remove the Spanish language.
  $spanish_language = $this->container
    ->get('entity_type.manager')
    ->getStorage('configurable_language')
    ->loadByProperties([
    'id' => 'es',
  ]);
  if (!empty($spanish_language['es']) && $spanish_language['es'] instanceof ConfigurableLanguageInterface) {
    $spanish_language['es']
      ->delete();
  }

  // Try to import Spanish values.
  $this
    ->importContent($this
    ->resourcesPath() . '/csv/translation/content_es.csv');
  $this
    ->assertNodeCount(1);

  // Check the imported values.
  $node = Node::load(1);
  $this
    ->assertEquals('HOLA MUNDO', $node->title->value);
  $this
    ->assertFalse($node
    ->hasTranslation('es'));
}