function JsonTest::testEncodingLength

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/Serialization/JsonTest.php \Drupal\Tests\Component\Serialization\JsonTest::testEncodingLength()
  2. 8.9.x core/tests/Drupal/Tests/Component/Serialization/JsonTest.php \Drupal\Tests\Component\Serialization\JsonTest::testEncodingLength()
  3. 11.x core/tests/Drupal/Tests/Component/Serialization/JsonTest.php \Drupal\Tests\Component\Serialization\JsonTest::testEncodingLength()

Tests encoding length.

File

core/tests/Drupal/Tests/Component/Serialization/JsonTest.php, line 71

Class

JsonTest
@coversDefaultClass \Drupal\Component\Serialization\Json[[api-linebreak]] @group Serialization

Namespace

Drupal\Tests\Component\Serialization

Code

public function testEncodingLength() : void {
  // Verify that JSON encoding produces a string with all of the characters.
  $json = Json::encode($this->string);
  // Verify that a JSON-encoded string is larger than the source string.
  $this->assertGreaterThan(strlen($this->string), strlen($json));
}

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