You are here

public function PhpTransliterationTest::testTransliterationWithMaxLength in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Component/Transliteration/PhpTransliterationTest.php \Drupal\Tests\Component\Transliteration\PhpTransliterationTest::testTransliterationWithMaxLength()

Tests the transliteration with max length.

File

core/tests/Drupal/Tests/Component/Transliteration/PhpTransliterationTest.php, line 160
Contains \Drupal\Tests\Component\Transliteration\PhpTransliterationTest.

Class

PhpTransliterationTest
Tests Transliteration component functionality.

Namespace

Drupal\Tests\Component\Transliteration

Code

public function testTransliterationWithMaxLength() {
  $transliteration = new PhpTransliteration();

  // Test with max length, using German. It should never split up the
  // transliteration of a single character.
  $input = 'Ä Ö Ü Å Ø äöüåøhello';
  $trunc_output = 'Ae Oe Ue A O aeoe';
  $this
    ->assertSame($trunc_output, $transliteration
    ->transliterate($input, 'de', '?', 17), 'Truncating to 17 characters works');
  $this
    ->assertSame($trunc_output, $transliteration
    ->transliterate($input, 'de', '?', 18), 'Truncating to 18 characters works');
}