You are here

public function UnicodeTest::providerTestValidateUtf8 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::providerTestValidateUtf8()

Provides data for self::testValidateUtf8().

Return value

array An array of arrays, each containing the parameters for self::testValidateUtf8().

Invalid UTF-8 examples sourced from http://stackoverflow.com/a/11709412/109119.

File

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

Class

UnicodeTest
Test unicode handling features implemented in Unicode component.

Namespace

Drupal\Tests\Component\Utility

Code

public function providerTestValidateUtf8() {
  return array(
    // Empty string.
    array(
      '',
      TRUE,
      'An empty string did not validate.',
    ),
    // Simple text string.
    array(
      'Simple text.',
      TRUE,
      'A simple ASCII text string did not validate.',
    ),
    // Invalid UTF-8, overlong 5 byte encoding.
    array(
      chr(0xf8) . chr(0x80) . chr(0x80) . chr(0x80) . chr(0x80),
      FALSE,
      'Invalid UTF-8 was validated.',
    ),
    // High code-point without trailing characters.
    array(
      chr(0xd0) . chr(0x1),
      FALSE,
      'Invalid UTF-8 was validated.',
    ),
  );
}