Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / migrate_plus / tests / src / Unit / process / TransliterationTest.php
diff --git a/web/modules/contrib/migrate_plus/tests/src/Unit/process/TransliterationTest.php b/web/modules/contrib/migrate_plus/tests/src/Unit/process/TransliterationTest.php
new file mode 100644 (file)
index 0000000..dbfe288
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+
+namespace Drupal\Tests\migrate_plus\Unit\process;
+
+use Drupal\Component\Transliteration\PhpTransliteration;
+use Drupal\migrate\MigrateExecutableInterface;
+use Drupal\migrate\Row;
+use Drupal\migrate_plus\Plugin\migrate\process\Transliteration;
+use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
+
+/**
+ * Tests the transliteration process plugin.
+ *
+ * @group migrate_plus
+ */
+class TransliterationTest extends MigrateProcessTestCase {
+
+  /**
+   * A transliteration instance.
+   *
+   * @var \Drupal\Component\Transliteration\TransliterationInterface
+   */
+  protected $transliteration;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    $this->transliteration = new PhpTransliteration();
+    $this->row = $this->getMockBuilder(Row::class)
+      ->disableOriginalConstructor()
+      ->getMock();
+    $this->migrateExecutable = $this->getMockBuilder(MigrateExecutableInterface::class)
+      ->disableOriginalConstructor()
+      ->getMock();
+    parent::setUp();
+  }
+
+  /**
+   * Tests transliteration transformation of non-alphanumeric characters.
+   */
+  public function testTransform() {
+    $actual = '9000004351_53494854_Spøgelsesjægerneáéö';
+    $expected_result = '9000004351_53494854_Spogelsesjaegerneaeo';
+
+    $plugin = new Transliteration([], 'transliteration', [], $this->transliteration);
+    $value = $plugin->transform($actual, $this->migrateExecutable, $this->row, 'destinationproperty');
+    $this->assertEquals($expected_result, $value);
+  }
+
+}