You are here

public function UnicodeTest::testSubstr in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php \Drupal\Tests\Component\Utility\UnicodeTest::testSubstr()

Tests multibyte substr.

@dataProvider providerSubstr @covers ::substr

File

core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php, line 304
Contains \Drupal\Tests\Component\Utility\UnicodeTest.

Class

UnicodeTest
Test unicode handling features implemented in Unicode component.

Namespace

Drupal\Tests\Component\Utility

Code

public function testSubstr($text, $start, $length, $expected) {

  // Run through multibyte code path.
  Unicode::setStatus(Unicode::STATUS_MULTIBYTE);
  $this
    ->assertEquals($expected, Unicode::substr($text, $start, $length));

  // Run through singlebyte code path.
  Unicode::setStatus(Unicode::STATUS_SINGLEBYTE);
  $this
    ->assertEquals($expected, Unicode::substr($text, $start, $length));
}