You are here

public function JsonTest::testEncodingAscii in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Component/Serialization/JsonTest.php \Drupal\Tests\Component\Serialization\JsonTest::testEncodingAscii()

Tests encoding for every ASCII character.

File

core/tests/Drupal/Tests/Component/Serialization/JsonTest.php, line 64
Contains \Drupal\Tests\Component\Serialization\JsonTest.

Class

JsonTest
@coversDefaultClass \Drupal\Component\Serialization\Json @group Serialization

Namespace

Drupal\Tests\Component\Serialization

Code

public function testEncodingAscii() {

  // Verify there aren't character encoding problems with the source string.
  $this
    ->assertSame(strlen($this->string), 127, 'A string with the full ASCII table has the correct length.');
  foreach ($this->htmlUnsafe as $char) {
    $this
      ->assertTrue(strpos($this->string, $char) > 0, sprintf('A string with the full ASCII table includes %s.', $char));
  }
}