function JsonTest::testEncodingStartEnd
Same name and namespace in other branches
- 8.9.x core/tests/Drupal/Tests/Component/Serialization/JsonTest.php \Drupal\Tests\Component\Serialization\JsonTest::testEncodingStartEnd()
- 10 core/tests/Drupal/Tests/Component/Serialization/JsonTest.php \Drupal\Tests\Component\Serialization\JsonTest::testEncodingStartEnd()
- 11.x core/tests/Drupal/Tests/Component/Serialization/JsonTest.php \Drupal\Tests\Component\Serialization\JsonTest::testEncodingStartEnd()
Tests end and start of the encoded string.
File
-
core/
tests/ Drupal/ Tests/ Component/ Serialization/ JsonTest.php, line 79
Class
- JsonTest
- @coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21Serialization%21Json.php/class/Json/9" title="Default serialization for JSON." class="local">\Drupal\Component\Serialization\Json</a> @group Serialization
Namespace
Drupal\Tests\Component\SerializationCode
public function testEncodingStartEnd() {
$json = Json::encode($this->string);
// The first and last characters should be ", and no others.
$this->assertStringStartsWith('"', $json, 'A JSON encoded string begins with ".');
$this->assertStringEndsWith('"', $json, 'A JSON encoded string ends with ".');
$this->assertSame(2, substr_count($json, '"'), 'A JSON encoded string contains exactly two ".');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.