You are here

public function TranslationTest::testImportInProcessorConfiguredLanguage in Feeds 8.3

Tests that the language setting on the processor is respected.

In this case there's no language configured on the targets.

File

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

Class

TranslationTest
Test for the entity field translation.

Namespace

Drupal\Tests\feeds\Kernel\Feeds\Target

Code

public function testImportInProcessorConfiguredLanguage() {

  // Set language to Spanish.
  $configuration = $this->feedType
    ->getProcessor()
    ->getConfiguration();
  $configuration['langcode'] = 'es';
  $this->feedType
    ->getProcessor()
    ->setConfiguration($configuration);

  // Set mappings without configuring language.
  $this->feedType
    ->setMappings($this
    ->getMappingsInLanguage(NULL));
  $this->feedType
    ->save();

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

  // Assert that Spanish values were created.
  $node = Node::load(1);
  $this
    ->assertEquals('es', $node
    ->language()
    ->getId());
  $this
    ->assertEquals('HOLA MUNDO', $node->title->value);
  $this
    ->assertEquals('Este es el texto del cuerpo.', $node->field_alpha->value);

  // Assert that the created term is in the Spanish language.
  $term = Term::load(1);
  $this
    ->assertEquals('Termino de taxonomía', $term->name->value);
  $this
    ->assertEquals('es', $term->langcode->value);
}