LanguageTest.php in Feeds 8.3
File
tests/src/Kernel/Feeds/Target/LanguageTest.php
View source
<?php
namespace Drupal\Tests\feeds\Kernel\Feeds\Target;
use Drupal\node\Entity\Node;
use Drupal\Tests\feeds\Kernel\FeedsKernelTestBase;
class LanguageTest extends FeedsKernelTestBase {
protected $feedType;
public static $modules = [
'field',
'node',
'feeds',
'text',
'filter',
'language',
];
public function setUp() {
parent::setUp();
$language = $this->container
->get('entity_type.manager')
->getStorage('configurable_language')
->create([
'id' => 'es',
]);
$language
->save();
$this->feedType = $this
->createFeedTypeForCsv([
'guid' => 'guid',
'title' => 'title',
'langcode' => 'langcode',
]);
}
public function testImportLanguage() {
$this->feedType
->addMapping([
'target' => 'langcode',
'map' => [
'value' => 'langcode',
],
]);
$this->feedType
->save();
$feed = $this
->createFeed($this->feedType
->id(), [
'source' => $this
->resourcesPath() . '/csv/content_language.csv',
]);
$feed
->import();
$this
->assertNodeCount(2);
$expected = [
1 => 'und',
2 => 'es',
];
foreach ($expected as $nid => $value) {
$node = Node::load($nid);
$this
->assertEquals($value, $node->langcode->value);
}
}
}