12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace Composer\Test\Json;
- use Composer\Json\JsonFormatter;
- class JsonFormatterTest extends \PHPUnit_Framework_TestCase
- {
-
- public function testUnicodeWithPrependedSlash()
- {
- if (!extension_loaded('mbstring')) {
- $this->markTestSkipped('Test requires the mbstring extension');
- }
- $data = '"' . chr(92) . chr(92) . chr(92) . 'u0119"';
- $encodedData = JsonFormatter::format($data, true, true);
- $expected = '34+92+92+196+153+34';
- $this->assertEquals($expected, $this->getCharacterCodes($encodedData));
- }
-
- protected function getCharacterCodes($string)
- {
- $codes = array();
- for ($i = 0; $i < strlen($string); $i++) {
- $codes[] = ord($string[$i]);
- }
- return implode('+', $codes);
- }
- }
|