function JsonTest::testEncodingAscii

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Component/Serialization/JsonTest.php \Drupal\Tests\Component\Serialization\JsonTest::testEncodingAscii()
  2. 8.9.x core/tests/Drupal/Tests/Component/Serialization/JsonTest.php \Drupal\Tests\Component\Serialization\JsonTest::testEncodingAscii()
  3. 10 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 60

Class

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

Namespace

Drupal\Tests\Component\Serialization

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.