3 namespace Drupal\Tests\language\Unit\process;
5 use Drupal\language\Plugin\migrate\process\LanguageTypes;
6 use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
7 use Drupal\migrate\MigrateException;
10 * @coversDefaultClass \Drupal\language\Plugin\migrate\process\LanguageTypes
13 class LanguageTypesTest extends MigrateProcessTestCase {
16 * Tests successful transformation of all language types.
18 public function testTransformAll() {
19 $this->plugin = new LanguageTypes([], 'map', []);
22 'language_url' => FALSE,
23 'language_content' => FALSE,
27 1 => 'language_content',
28 2 => 'language_interface',
30 $value = $this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destinationproperty');
31 $this->assertSame($value, $expected);
35 * Tests successful transformation of configurable language types.
37 public function testTransformConfigurable() {
38 $this->plugin = new LanguageTypes(['filter_configurable' => TRUE], 'map', []);
41 'language_url' => FALSE,
42 'language_content' => FALSE,
45 0 => 'language_interface',
47 $value = $this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destinationproperty');
48 $this->assertSame($value, $expected);
54 public function testStringInput() {
55 $this->plugin = new LanguageTypes([], 'map', []);
56 $this->setExpectedException(MigrateException::class, 'The input should be an array');
57 $this->plugin->transform('foo', $this->migrateExecutable, $this->row, 'destinationproperty');