You are here

public function LanguageTest::testImportLanguage in Feeds 8.3

Tests importing a content with a specific language.

File

tests/src/Kernel/Feeds/Target/LanguageTest.php, line 57

Class

LanguageTest
@coversDefaultClass \Drupal\feeds\Feeds\Target\Language @group feeds

Namespace

Drupal\Tests\feeds\Kernel\Feeds\Target

Code

public function testImportLanguage() {
  $this->feedType
    ->addMapping([
    'target' => 'langcode',
    'map' => [
      'value' => 'langcode',
    ],
  ]);
  $this->feedType
    ->save();

  // Import.
  $feed = $this
    ->createFeed($this->feedType
    ->id(), [
    'source' => $this
      ->resourcesPath() . '/csv/content_language.csv',
  ]);
  $feed
    ->import();

  // Assert two created nodes.
  $this
    ->assertNodeCount(2);
  $expected = [
    1 => 'und',
    2 => 'es',
  ];
  foreach ($expected as $nid => $value) {
    $node = Node::load($nid);
    $this
      ->assertEquals($value, $node->langcode->value);
  }
}