blob: 1c34efb999e6f97484b015b4aeae2978851d18af [file] [log] [blame]
Roger Meier21c0a852012-09-05 19:47:14 +00001<?php
2
3/*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 *
21 * @package thrift.test
22 */
23
24namespace test\Thrift\Protocol;
25
26use Thrift\ClassLoader\ThriftClassLoader;
27use Test\Thrift\Fixtures;
28use Thrift\Transport\TMemoryBuffer;
29use Thrift\Protocol\TJSONProtocol;
30
Roger Meier21c0a852012-09-05 19:47:14 +000031define( 'BUFSIZ', 8192 ); //big enough to read biggest serialized Fixture arg.
32
Robert Lubfba3702017-11-03 12:27:31 +080033require_once __DIR__.'/../../../../vendor/autoload.php';
Roger Meier21c0a852012-09-05 19:47:14 +000034
35$loader = new ThriftClassLoader();
Robert Lubfba3702017-11-03 12:27:31 +080036$loader->registerDefinition('ThriftTest', __DIR__ . '/../packages');
Roger Meier21c0a852012-09-05 19:47:14 +000037$loader->register();
38
39/***
40 * This test suite depends on running the compiler against the
41 * standard ThriftTest.thrift file:
42 *
43 * lib/php/test$ ../../../compiler/cpp/thrift --gen php -r \
44 * --out ./packages ../../../test/ThriftTest.thrift
45 */
46
47class TestTJSONProtocol extends \PHPUnit_Framework_TestCase
48{
49 private $transport;
50 private $protocol;
51
52 public static function setUpBeforeClass()
53 {
54 Fixtures::populateTestArgs();
55 TestTJSONProtocol_Fixtures::populateTestArgsJSON();
56 }
57
58 public function setUp()
59 {
60 $this->transport = new TMemoryBuffer();
61 $this->protocol = new TJSONProtocol($this->transport);
62 $this->transport->open();
63 }
64
65 /***
66 * WRITE TESTS
67 */
68
69 public function testVoid_Write()
70 {
71 $args = new \ThriftTest\ThriftTest_testVoid_args();
72 $args->write( $this->protocol );
73
74 $actual = $this->transport->read( BUFSIZ );
75 $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testVoid'];
76
77 $this->assertEquals( $expected, $actual );
78 }
79
80 public function testString1_Write()
81 {
82 $args = new \ThriftTest\ThriftTest_testString_args();
83 $args->thing = Fixtures::$testArgs['testString1'];
84 $args->write( $this->protocol );
85
86 $actual = $this->transport->read( BUFSIZ );
87 $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testString1'];
88
89 #$this->assertEquals( $expected, $actual );
90 }
91
92 public function testString2_Write()
93 {
94 $args = new \ThriftTest\ThriftTest_testString_args();
95 $args->thing = Fixtures::$testArgs['testString2'];
96 $args->write( $this->protocol );
97
98 $actual = $this->transport->read( BUFSIZ );
99 $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testString2'];
100
101 $this->assertEquals( $expected, $actual );
102 }
103
104 public function testDouble_Write()
105 {
106 $args = new \ThriftTest\ThriftTest_testDouble_args();
107 $args->thing = Fixtures::$testArgs['testDouble'];
108 $args->write( $this->protocol );
109
110 $actual = $this->transport->read( BUFSIZ );
111 $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testDouble'];
112
113 $this->assertEquals( $expected, $actual );
114 }
115
116 public function testByte_Write()
117 {
118 $args = new \ThriftTest\ThriftTest_testByte_args();
119 $args->thing = Fixtures::$testArgs['testByte'];
120 $args->write( $this->protocol );
121
122 $actual = $this->transport->read( BUFSIZ );
123 $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testByte'];
124
125 $this->assertEquals( $expected, $actual );
126 }
127
128 public function testI32_Write()
129 {
130 $args = new \ThriftTest\ThriftTest_testI32_args();
131 $args->thing = Fixtures::$testArgs['testI32'];
132 $args->write( $this->protocol );
133
134 $actual = $this->transport->read( BUFSIZ );
135 $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testI32'];
136
137 $this->assertEquals( $expected, $actual );
138 }
139
140 public function testI64_Write()
141 {
142 $args = new \ThriftTest\ThriftTest_testI64_args();
143 $args->thing = Fixtures::$testArgs['testI64'];
144 $args->write( $this->protocol );
145
146 $actual = $this->transport->read( BUFSIZ );
147 $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testI64'];
148
149 $this->assertEquals( $expected, $actual );
150 }
151
152 public function testStruct_Write()
153 {
154 $args = new \ThriftTest\ThriftTest_testStruct_args();
155 $args->thing = Fixtures::$testArgs['testStruct'];
156
157 $args->write( $this->protocol );
158
159 $actual = $this->transport->read( BUFSIZ );
160 $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testStruct'];
161
162 $this->assertEquals( $expected, $actual );
163 }
164
165 public function testNest_Write()
166 {
167 $args = new \ThriftTest\ThriftTest_testNest_args();
168 $args->thing = Fixtures::$testArgs['testNest'];
169
170 $args->write( $this->protocol );
171
172 $actual = $this->transport->read( BUFSIZ );
173 $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testNest'];
174
175 $this->assertEquals( $expected, $actual );
176 }
177
178 public function testMap_Write()
179 {
180 $args = new \ThriftTest\ThriftTest_testMap_args();
181 $args->thing = Fixtures::$testArgs['testMap'];
182
183 $args->write( $this->protocol );
184
185 $actual = $this->transport->read( BUFSIZ );
186 $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testMap'];
187
188 $this->assertEquals( $expected, $actual );
189 }
190
191 public function testStringMap_Write()
192 {
193 $args = new \ThriftTest\ThriftTest_testStringMap_args();
194 $args->thing = Fixtures::$testArgs['testStringMap'];
195
196 $args->write( $this->protocol );
197
198 $actual = $this->transport->read( BUFSIZ );
199 $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testStringMap'];
200
Phongphan Phuttha90ea4f62015-10-30 00:00:10 +0700201 /*
202 * The $actual returns unescaped string.
203 * It is required to to decode then encode it again
204 * to get the expected escaped unicode.
205 */
206 $this->assertEquals( $expected, json_encode(json_decode($actual)) );
Roger Meier21c0a852012-09-05 19:47:14 +0000207 }
208
209 public function testSet_Write()
210 {
211 $args = new \ThriftTest\ThriftTest_testSet_args();
212 $args->thing = Fixtures::$testArgs['testSet'];
213
214 $args->write( $this->protocol );
215
216 $actual = $this->transport->read( BUFSIZ );
217 $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testSet'];
218
219 $this->assertEquals( $expected, $actual );
220 }
221
222 public function testList_Write()
223 {
224 $args = new \ThriftTest\ThriftTest_testList_args();
225 $args->thing = Fixtures::$testArgs['testList'];
226
227 $args->write( $this->protocol );
228
229 $actual = $this->transport->read( BUFSIZ );
230 $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testList'];
231
232 $this->assertEquals( $expected, $actual );
233 }
234
235 public function testEnum_Write()
236 {
237 $args = new \ThriftTest\ThriftTest_testEnum_args();
238 $args->thing = Fixtures::$testArgs['testEnum'];
239
240 $args->write( $this->protocol );
241
242 $actual = $this->transport->read( BUFSIZ );
243 $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testEnum'];
244
245 $this->assertEquals( $expected, $actual );
246 }
247
248 public function testTypedef_Write()
249 {
250 $args = new \ThriftTest\ThriftTest_testTypedef_args();
251 $args->thing = Fixtures::$testArgs['testTypedef'];
252
253 $args->write( $this->protocol );
254
255 $actual = $this->transport->read( BUFSIZ );
256 $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testTypedef'];
257
258 $this->assertEquals( $expected, $actual );
259 }
260
261 /***
262 * READ TESTS
263 */
264
265 public function testVoid_Read()
266 {
267 $this->transport->write(
Roger Thomas6fb59232014-11-04 10:09:23 +0000268 TestTJSONProtocol_Fixtures::$testArgsJSON['testVoid']
269 );
Roger Meier21c0a852012-09-05 19:47:14 +0000270 $args = new \ThriftTest\ThriftTest_testVoid_args();
271 $args->read( $this->protocol );
272 }
273
274 public function testString1_Read()
275 {
276 $this->transport->write(
Roger Thomas6fb59232014-11-04 10:09:23 +0000277 TestTJSONProtocol_Fixtures::$testArgsJSON['testString1']
278 );
Roger Meier21c0a852012-09-05 19:47:14 +0000279 $args = new \ThriftTest\ThriftTest_testString_args();
280 $args->read( $this->protocol );
281
282 $actual = $args->thing;
283 $expected = Fixtures::$testArgs['testString1'];
284
285 $this->assertEquals( $expected, $actual );
286 }
287
288 public function testString2_Read()
289 {
290 $this->transport->write(
Roger Thomas6fb59232014-11-04 10:09:23 +0000291 TestTJSONProtocol_Fixtures::$testArgsJSON['testString2']
292 );
Roger Meier21c0a852012-09-05 19:47:14 +0000293 $args = new \ThriftTest\ThriftTest_testString_args();
294 $args->read( $this->protocol );
295
296 $actual = $args->thing;
297 $expected = Fixtures::$testArgs['testString2'];
298
299 $this->assertEquals( $expected, $actual );
300 }
301
302 public function testString3_Write()
303 {
304 $args = new \ThriftTest\ThriftTest_testString_args();
305 $args->thing = Fixtures::$testArgs['testString3'];
306 $args->write( $this->protocol );
307
308 $actual = $this->transport->read( BUFSIZ );
309 $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testString3'];
310
311 $this->assertEquals( $expected, $actual );
312 }
313
Phongphan Phuttha90ea4f62015-10-30 00:00:10 +0700314 public function testString4_Write()
315 {
316 $args = new \ThriftTest\ThriftTest_testString_args();
317 $args->thing = Fixtures::$testArgs['testUnicodeStringWithNonBMP'];
318 $args->write( $this->protocol );
319
320 $actual = $this->transport->read( BUFSIZ );
321 $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testUnicodeStringWithNonBMP'];
322
323 $this->assertEquals( $expected, $actual );
324 }
325
Roger Meier21c0a852012-09-05 19:47:14 +0000326 public function testDouble_Read()
327 {
328 $this->transport->write(
Roger Thomas6fb59232014-11-04 10:09:23 +0000329 TestTJSONProtocol_Fixtures::$testArgsJSON['testDouble']
330 );
Roger Meier21c0a852012-09-05 19:47:14 +0000331 $args = new \ThriftTest\ThriftTest_testDouble_args();
332 $args->read( $this->protocol );
333
334 $actual = $args->thing;
335 $expected = Fixtures::$testArgs['testDouble'];
336
337 $this->assertEquals( $expected, $actual );
338 }
339
340 public function testByte_Read()
341 {
342 $this->transport->write(
Roger Thomas6fb59232014-11-04 10:09:23 +0000343 TestTJSONProtocol_Fixtures::$testArgsJSON['testByte']
344 );
Roger Meier21c0a852012-09-05 19:47:14 +0000345 $args = new \ThriftTest\ThriftTest_testByte_args();
346 $args->read( $this->protocol );
347
348 $actual = $args->thing;
349 $expected = Fixtures::$testArgs['testByte'];
350
351 $this->assertEquals( $expected, $actual );
352 }
353
354 public function testI32_Read()
355 {
356 $this->transport->write(
Roger Thomas6fb59232014-11-04 10:09:23 +0000357 TestTJSONProtocol_Fixtures::$testArgsJSON['testI32']
358 );
Roger Meier21c0a852012-09-05 19:47:14 +0000359 $args = new \ThriftTest\ThriftTest_testI32_args();
360 $args->read( $this->protocol );
361
362 $actual = $args->thing;
363 $expected = Fixtures::$testArgs['testI32'];
364
365 $this->assertEquals( $expected, $actual );
366 }
367
368 public function testI64_Read()
369 {
370 $this->transport->write(
Roger Thomas6fb59232014-11-04 10:09:23 +0000371 TestTJSONProtocol_Fixtures::$testArgsJSON['testI64']
372 );
Roger Meier21c0a852012-09-05 19:47:14 +0000373 $args = new \ThriftTest\ThriftTest_testI64_args();
374 $args->read( $this->protocol );
375
376 $actual = $args->thing;
377 $expected = Fixtures::$testArgs['testI64'];
378
379 $this->assertEquals( $expected, $actual );
380
381 }
382
383 public function testStruct_Read()
384 {
385 $this->transport->write(
Roger Thomas6fb59232014-11-04 10:09:23 +0000386 TestTJSONProtocol_Fixtures::$testArgsJSON['testStruct']
387 );
Roger Meier21c0a852012-09-05 19:47:14 +0000388 $args = new \ThriftTest\ThriftTest_testStruct_args();
389 $args->read( $this->protocol );
390
391 $actual = $args->thing;
392 $expected = Fixtures::$testArgs['testStruct'];
393
394 $this->assertEquals( $expected, $actual );
395
396 }
397
398 public function testNest_Read()
399 {
400 $this->transport->write(
Roger Thomas6fb59232014-11-04 10:09:23 +0000401 TestTJSONProtocol_Fixtures::$testArgsJSON['testNest']
402 );
Roger Meier21c0a852012-09-05 19:47:14 +0000403 $args = new \ThriftTest\ThriftTest_testNest_args();
404 $args->read( $this->protocol );
405
406 $actual = $args->thing;
407 $expected = Fixtures::$testArgs['testNest'];
408
409 $this->assertEquals( $expected, $actual );
410
411 }
412
413 public function testMap_Read()
414 {
415 $this->transport->write(
Roger Thomas6fb59232014-11-04 10:09:23 +0000416 TestTJSONProtocol_Fixtures::$testArgsJSON['testMap']
417 );
Roger Meier21c0a852012-09-05 19:47:14 +0000418 $args = new \ThriftTest\ThriftTest_testMap_args();
419 $args->read( $this->protocol );
420
421 $actual = $args->thing;
422 $expected = Fixtures::$testArgs['testMap'];
423
424 $this->assertEquals( $expected, $actual );
425
426 }
427
428 public function testStringMap_Read()
429 {
430 $this->transport->write(
Roger Thomas6fb59232014-11-04 10:09:23 +0000431 TestTJSONProtocol_Fixtures::$testArgsJSON['testStringMap']
432 );
Roger Meier21c0a852012-09-05 19:47:14 +0000433 $args = new \ThriftTest\ThriftTest_testStringMap_args();
434 $args->read( $this->protocol );
435
436 $actual = $args->thing;
437 $expected = Fixtures::$testArgs['testStringMap'];
438
439 $this->assertEquals( $expected, $actual );
440
441 }
442
443 public function testSet_Read()
444 {
445 $this->transport->write(
Roger Thomas6fb59232014-11-04 10:09:23 +0000446 TestTJSONProtocol_Fixtures::$testArgsJSON['testSet']
447 );
Roger Meier21c0a852012-09-05 19:47:14 +0000448 $args = new \ThriftTest\ThriftTest_testSet_args();
449 $args->read( $this->protocol );
450
451 $actual = $args->thing;
452 $expected = Fixtures::$testArgs['testSet'];
453
454 $this->assertEquals( $expected, $actual );
455
456 }
457
458 public function testList_Read()
459 {
460 $this->transport->write(
Roger Thomas6fb59232014-11-04 10:09:23 +0000461 TestTJSONProtocol_Fixtures::$testArgsJSON['testList']
462 );
Roger Meier21c0a852012-09-05 19:47:14 +0000463 $args = new \ThriftTest\ThriftTest_testList_args();
464 $args->read( $this->protocol );
465
466 $actual = $args->thing;
467 $expected = Fixtures::$testArgs['testList'];
468
469 $this->assertEquals( $expected, $actual );
470
471 }
472
473 public function testEnum_Read()
474 {
475 $this->transport->write(
Roger Thomas6fb59232014-11-04 10:09:23 +0000476 TestTJSONProtocol_Fixtures::$testArgsJSON['testEnum']
477 );
Roger Meier21c0a852012-09-05 19:47:14 +0000478 $args = new \ThriftTest\ThriftTest_testEnum_args();
479 $args->read( $this->protocol );
480
481 $actual = $args->thing;
482 $expected = Fixtures::$testArgs['testEnum'];
483
484 $this->assertEquals( $expected, $actual );
485
486 }
487
488 public function testTypedef_Read()
489 {
490 $this->transport->write(
Roger Thomas6fb59232014-11-04 10:09:23 +0000491 TestTJSONProtocol_Fixtures::$testArgsJSON['testTypedef']
492 );
Roger Meier21c0a852012-09-05 19:47:14 +0000493 $args = new \ThriftTest\ThriftTest_testTypedef_args();
494 $args->read( $this->protocol );
495
496 $actual = $args->thing;
497 $expected = Fixtures::$testArgs['testTypedef'];
498
499 $this->assertEquals( $expected, $actual );
500 }
501
502 public function testMapMap_Read()
503 {
504 $this->transport->write(
Roger Thomas6fb59232014-11-04 10:09:23 +0000505 TestTJSONProtocol_Fixtures::$testArgsJSON['testMapMap']
506 );
Roger Meier21c0a852012-09-05 19:47:14 +0000507 $result = new \ThriftTest\ThriftTest_testMapMap_result();
508 $result->read( $this->protocol );
509
510 $actual = $result->success;
511 $expected = Fixtures::$testArgs['testMapMapExpectedResult'];
512
513 $this->assertEquals( $expected, $actual );
514 }
515
516 public function testInsanity_Read()
517 {
518 $this->transport->write(
Roger Thomas6fb59232014-11-04 10:09:23 +0000519 TestTJSONProtocol_Fixtures::$testArgsJSON['testInsanity']
520 );
Roger Meier21c0a852012-09-05 19:47:14 +0000521 $result = new \ThriftTest\ThriftTest_testInsanity_result();
522 $result->read( $this->protocol );
523
524 $actual = $result->success;
525 $expected = Fixtures::$testArgs['testInsanityExpectedResult'];
526
527 $this->assertEquals( $expected, $actual );
528 }
529
530}
531
532class TestTJSONProtocol_Fixtures
533{
534 public static $testArgsJSON = array();
535
536 public static function populateTestArgsJSON()
537 {
538 self::$testArgsJSON['testVoid'] = '{}';
539
540 self::$testArgsJSON['testString1'] = '{"1":{"str":"Afrikaans, Alemannisch, Aragon\u00e9s, \u0627\u0644\u0639\u0631\u0628\u064a\u0629, \u0645\u0635\u0631\u0649, Asturianu, Aymar aru, Az\u0259rbaycan, \u0411\u0430\u0448\u04a1\u043e\u0440\u0442, Boarisch, \u017demait\u0117\u0161ka, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f (\u0442\u0430\u0440\u0430\u0448\u043a\u0435\u0432\u0456\u0446\u0430), \u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438, Bamanankan, \u09ac\u09be\u0982\u09b2\u09be, Brezhoneg, Bosanski, Catal\u00e0, M\u00ecng-d\u0115\u0324ng-ng\u1e73\u0304, \u041d\u043e\u0445\u0447\u0438\u0439\u043d, Cebuano, \u13e3\u13b3\u13a9, \u010cesky, \u0421\u043b\u043e\u0432\u0463\u0301\u043d\u044c\u0441\u043a\u044a \/ \u2c14\u2c0e\u2c11\u2c02\u2c21\u2c10\u2c20\u2c14\u2c0d\u2c1f, \u0427\u04d1\u0432\u0430\u0448\u043b\u0430, Cymraeg, Dansk, Zazaki, \u078b\u07a8\u0788\u07ac\u0780\u07a8\u0784\u07a6\u0790\u07b0, \u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac, Emili\u00e0n e rumagn\u00f2l, English, Esperanto, Espa\u00f1ol, Eesti, Euskara, \u0641\u0627\u0631\u0633\u06cc, Suomi, V\u00f5ro, F\u00f8royskt, Fran\u00e7ais, Arpetan, Furlan, Frysk, Gaeilge, \u8d1b\u8a9e, G\u00e0idhlig, Galego, Ava\u00f1e\'\u1ebd, \u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0, Gaelg, \u05e2\u05d1\u05e8\u05d9\u05ea, \u0939\u093f\u0928\u094d\u0926\u0940, Fiji Hindi, Hrvatski, Krey\u00f2l ayisyen, Magyar, \u0540\u0561\u0575\u0565\u0580\u0565\u0576, Interlingua, Bahasa Indonesia, Ilokano, Ido, \u00cdslenska, Italiano, \u65e5\u672c\u8a9e, Lojban, Basa Jawa, \u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8, Kongo, Kalaallisut, \u0c95\u0ca8\u0ccd\u0ca8\u0ca1, \ud55c\uad6d\uc5b4, \u041a\u044a\u0430\u0440\u0430\u0447\u0430\u0439-\u041c\u0430\u043b\u043a\u044a\u0430\u0440, Ripoarisch, Kurd\u00ee, \u041a\u043e\u043c\u0438, Kernewek, \u041a\u044b\u0440\u0433\u044b\u0437\u0447\u0430, Latina, Ladino, L\u00ebtzebuergesch, Limburgs, Ling\u00e1la, \u0ea5\u0eb2\u0ea7, Lietuvi\u0173, Latvie\u0161u, Basa Banyumasan, Malagasy, \u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438, \u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02, \u092e\u0930\u093e\u0920\u0940, Bahasa Melayu, \u0645\u0627\u0632\u0650\u0631\u0648\u0646\u06cc, Nnapulitano, Nedersaksisch, \u0928\u0947\u092a\u093e\u0932 \u092d\u093e\u0937\u093e, Nederlands, \u202aNorsk (nynorsk)\u202c, \u202aNorsk (bokm\u00e5l)\u202c, Nouormand, Din\u00e9 bizaad, Occitan, \u0418\u0440\u043e\u043d\u0430\u0443, Papiamentu, Deitsch, Norfuk \/ Pitkern, Polski, \u067e\u0646\u062c\u0627\u0628\u06cc, \u067e\u069a\u062a\u0648, Portugu\u00eas, Runa Simi, Rumantsch, Romani, Rom\u00e2n\u0103, \u0420\u0443\u0441\u0441\u043a\u0438\u0439, \u0421\u0430\u0445\u0430 \u0442\u044b\u043b\u0430, Sardu, Sicilianu, Scots, S\u00e1megiella, Simple English, Sloven\u010dina, Sloven\u0161\u010dina, \u0421\u0440\u043f\u0441\u043a\u0438 \/ Srpski, Seeltersk, Svenska, Kiswahili, \u0ba4\u0bae\u0bbf\u0bb4\u0bcd, \u0c24\u0c46\u0c32\u0c41\u0c17\u0c41, \u0422\u043e\u04b7\u0438\u043a\u04e3, \u0e44\u0e17\u0e22, T\u00fcrkmen\u00e7e, Tagalog, T\u00fcrk\u00e7e, \u0422\u0430\u0442\u0430\u0440\u0447\u0430\/Tatar\u00e7a, \u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430, \u0627\u0631\u062f\u0648, Ti\u1ebfng Vi\u1ec7t, Volap\u00fck, Walon, Winaray, \u5434\u8bed, isiXhosa, \u05d9\u05d9\u05b4\u05d3\u05d9\u05e9, Yor\u00f9b\u00e1, Ze\u00eauws, \u4e2d\u6587, B\u00e2n-l\u00e2m-g\u00fa, \u7cb5\u8a9e"}}';
541
542 self::$testArgsJSON['testString2'] = '{"1":{"str":"quote: \\\\\" backslash: forwardslash-escaped: \\\\\/ backspace: \\\\b formfeed: \f newline: \n return: \r tab: now-all-of-them-together: \"\\\\\\\\\/\\\\b\n\r\t now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><"}}';
543
544 self::$testArgsJSON['testString3'] = '{"1":{"str":"string that ends in double-backslash \\\\\\\\"}}';
545
Phongphan Phuttha90ea4f62015-10-30 00:00:10 +0700546 self::$testArgsJSON['testUnicodeStringWithNonBMP'] = '{"1":{"str":"สวัสดี\/𝒯"}}';
547
Roger Meier21c0a852012-09-05 19:47:14 +0000548 self::$testArgsJSON['testDouble'] = '{"1":{"dbl":3.1415926535898}}';
549
550 self::$testArgsJSON['testByte'] = '{"1":{"i8":1}}';
551
552 self::$testArgsJSON['testI32'] = '{"1":{"i32":1073741824}}';
553
Roger Thomas6fb59232014-11-04 10:09:23 +0000554 if (PHP_INT_SIZE == 8) {
Roger Meier87afaac2013-01-06 20:10:42 +0100555 self::$testArgsJSON['testI64'] = '{"1":{"i64":'.pow( 2, 60 ).'}}';
556 self::$testArgsJSON['testStruct'] = '{"1":{"rec":{"1":{"str":"worked"},"4":{"i8":1},"9":{"i32":1073741824},"11":{"i64":'.pow( 2, 60 ).'}}}}';
557 self::$testArgsJSON['testNest'] = '{"1":{"rec":{"1":{"i8":1},"2":{"rec":{"1":{"str":"worked"},"4":{"i8":1},"9":{"i32":1073741824},"11":{"i64":'.pow( 2, 60 ).'}}},"3":{"i32":32768}}}}';
Roger Thomas6fb59232014-11-04 10:09:23 +0000558 } else {
Roger Meier87afaac2013-01-06 20:10:42 +0100559 self::$testArgsJSON['testI64'] = '{"1":{"i64":1152921504606847000}}';
560 self::$testArgsJSON['testStruct'] = '{"1":{"rec":{"1":{"str":"worked"},"4":{"i8":1},"9":{"i32":1073741824},"11":{"i64":1152921504606847000}}}}';
561 self::$testArgsJSON['testNest'] = '{"1":{"rec":{"1":{"i8":1},"2":{"rec":{"1":{"str":"worked"},"4":{"i8":1},"9":{"i32":1073741824},"11":{"i64":1152921504606847000}}},"3":{"i32":32768}}}}';
562 }
Roger Meier21c0a852012-09-05 19:47:14 +0000563
564 self::$testArgsJSON['testMap'] = '{"1":{"map":["i32","i32",3,{"7":77,"8":88,"9":99}]}}';
565
566 self::$testArgsJSON['testStringMap'] = '{"1":{"map":["str","str",6,{"a":"123","a b":"with spaces ","same":"same","0":"numeric key","longValue":"Afrikaans, Alemannisch, Aragon\u00e9s, \u0627\u0644\u0639\u0631\u0628\u064a\u0629, \u0645\u0635\u0631\u0649, Asturianu, Aymar aru, Az\u0259rbaycan, \u0411\u0430\u0448\u04a1\u043e\u0440\u0442, Boarisch, \u017demait\u0117\u0161ka, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f (\u0442\u0430\u0440\u0430\u0448\u043a\u0435\u0432\u0456\u0446\u0430), \u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438, Bamanankan, \u09ac\u09be\u0982\u09b2\u09be, Brezhoneg, Bosanski, Catal\u00e0, M\u00ecng-d\u0115\u0324ng-ng\u1e73\u0304, \u041d\u043e\u0445\u0447\u0438\u0439\u043d, Cebuano, \u13e3\u13b3\u13a9, \u010cesky, \u0421\u043b\u043e\u0432\u0463\u0301\u043d\u044c\u0441\u043a\u044a \/ \u2c14\u2c0e\u2c11\u2c02\u2c21\u2c10\u2c20\u2c14\u2c0d\u2c1f, \u0427\u04d1\u0432\u0430\u0448\u043b\u0430, Cymraeg, Dansk, Zazaki, \u078b\u07a8\u0788\u07ac\u0780\u07a8\u0784\u07a6\u0790\u07b0, \u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac, Emili\u00e0n e rumagn\u00f2l, English, Esperanto, Espa\u00f1ol, Eesti, Euskara, \u0641\u0627\u0631\u0633\u06cc, Suomi, V\u00f5ro, F\u00f8royskt, Fran\u00e7ais, Arpetan, Furlan, Frysk, Gaeilge, \u8d1b\u8a9e, G\u00e0idhlig, Galego, Ava\u00f1e\'\u1ebd, \u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0, Gaelg, \u05e2\u05d1\u05e8\u05d9\u05ea, \u0939\u093f\u0928\u094d\u0926\u0940, Fiji Hindi, Hrvatski, Krey\u00f2l ayisyen, Magyar, \u0540\u0561\u0575\u0565\u0580\u0565\u0576, Interlingua, Bahasa Indonesia, Ilokano, Ido, \u00cdslenska, Italiano, \u65e5\u672c\u8a9e, Lojban, Basa Jawa, \u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8, Kongo, Kalaallisut, \u0c95\u0ca8\u0ccd\u0ca8\u0ca1, \ud55c\uad6d\uc5b4, \u041a\u044a\u0430\u0440\u0430\u0447\u0430\u0439-\u041c\u0430\u043b\u043a\u044a\u0430\u0440, Ripoarisch, Kurd\u00ee, \u041a\u043e\u043c\u0438, Kernewek, \u041a\u044b\u0440\u0433\u044b\u0437\u0447\u0430, Latina, Ladino, L\u00ebtzebuergesch, Limburgs, Ling\u00e1la, \u0ea5\u0eb2\u0ea7, Lietuvi\u0173, Latvie\u0161u, Basa Banyumasan, Malagasy, \u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438, \u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02, \u092e\u0930\u093e\u0920\u0940, Bahasa Melayu, \u0645\u0627\u0632\u0650\u0631\u0648\u0646\u06cc, Nnapulitano, Nedersaksisch, \u0928\u0947\u092a\u093e\u0932 \u092d\u093e\u0937\u093e, Nederlands, \u202aNorsk (nynorsk)\u202c, \u202aNorsk (bokm\u00e5l)\u202c, Nouormand, Din\u00e9 bizaad, Occitan, \u0418\u0440\u043e\u043d\u0430\u0443, Papiamentu, Deitsch, Norfuk \/ Pitkern, Polski, \u067e\u0646\u062c\u0627\u0628\u06cc, \u067e\u069a\u062a\u0648, Portugu\u00eas, Runa Simi, Rumantsch, Romani, Rom\u00e2n\u0103, \u0420\u0443\u0441\u0441\u043a\u0438\u0439, \u0421\u0430\u0445\u0430 \u0442\u044b\u043b\u0430, Sardu, Sicilianu, Scots, S\u00e1megiella, Simple English, Sloven\u010dina, Sloven\u0161\u010dina, \u0421\u0440\u043f\u0441\u043a\u0438 \/ Srpski, Seeltersk, Svenska, Kiswahili, \u0ba4\u0bae\u0bbf\u0bb4\u0bcd, \u0c24\u0c46\u0c32\u0c41\u0c17\u0c41, \u0422\u043e\u04b7\u0438\u043a\u04e3, \u0e44\u0e17\u0e22, T\u00fcrkmen\u00e7e, Tagalog, T\u00fcrk\u00e7e, \u0422\u0430\u0442\u0430\u0440\u0447\u0430\/Tatar\u00e7a, \u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430, \u0627\u0631\u062f\u0648, Ti\u1ebfng Vi\u1ec7t, Volap\u00fck, Walon, Winaray, \u5434\u8bed, isiXhosa, \u05d9\u05d9\u05b4\u05d3\u05d9\u05e9, Yor\u00f9b\u00e1, Ze\u00eauws, \u4e2d\u6587, B\u00e2n-l\u00e2m-g\u00fa, \u7cb5\u8a9e","Afrikaans, Alemannisch, Aragon\u00e9s, \u0627\u0644\u0639\u0631\u0628\u064a\u0629, \u0645\u0635\u0631\u0649, Asturianu, Aymar aru, Az\u0259rbaycan, \u0411\u0430\u0448\u04a1\u043e\u0440\u0442, Boarisch, \u017demait\u0117\u0161ka, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f (\u0442\u0430\u0440\u0430\u0448\u043a\u0435\u0432\u0456\u0446\u0430), \u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438, Bamanankan, \u09ac\u09be\u0982\u09b2\u09be, Brezhoneg, Bosanski, Catal\u00e0, M\u00ecng-d\u0115\u0324ng-ng\u1e73\u0304, \u041d\u043e\u0445\u0447\u0438\u0439\u043d, Cebuano, \u13e3\u13b3\u13a9, \u010cesky, \u0421\u043b\u043e\u0432\u0463\u0301\u043d\u044c\u0441\u043a\u044a \/ \u2c14\u2c0e\u2c11\u2c02\u2c21\u2c10\u2c20\u2c14\u2c0d\u2c1f, \u0427\u04d1\u0432\u0430\u0448\u043b\u0430, Cymraeg, Dansk, Zazaki, \u078b\u07a8\u0788\u07ac\u0780\u07a8\u0784\u07a6\u0790\u07b0, \u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac, Emili\u00e0n e rumagn\u00f2l, English, Esperanto, Espa\u00f1ol, Eesti, Euskara, \u0641\u0627\u0631\u0633\u06cc, Suomi, V\u00f5ro, F\u00f8royskt, Fran\u00e7ais, Arpetan, Furlan, Frysk, Gaeilge, \u8d1b\u8a9e, G\u00e0idhlig, Galego, Ava\u00f1e\'\u1ebd, \u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0, Gaelg, \u05e2\u05d1\u05e8\u05d9\u05ea, \u0939\u093f\u0928\u094d\u0926\u0940, Fiji Hindi, Hrvatski, Krey\u00f2l ayisyen, Magyar, \u0540\u0561\u0575\u0565\u0580\u0565\u0576, Interlingua, Bahasa Indonesia, Ilokano, Ido, \u00cdslenska, Italiano, \u65e5\u672c\u8a9e, Lojban, Basa Jawa, \u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8, Kongo, Kalaallisut, \u0c95\u0ca8\u0ccd\u0ca8\u0ca1, \ud55c\uad6d\uc5b4, \u041a\u044a\u0430\u0440\u0430\u0447\u0430\u0439-\u041c\u0430\u043b\u043a\u044a\u0430\u0440, Ripoarisch, Kurd\u00ee, \u041a\u043e\u043c\u0438, Kernewek, \u041a\u044b\u0440\u0433\u044b\u0437\u0447\u0430, Latina, Ladino, L\u00ebtzebuergesch, Limburgs, Ling\u00e1la, \u0ea5\u0eb2\u0ea7, Lietuvi\u0173, Latvie\u0161u, Basa Banyumasan, Malagasy, \u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438, \u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02, \u092e\u0930\u093e\u0920\u0940, Bahasa Melayu, \u0645\u0627\u0632\u0650\u0631\u0648\u0646\u06cc, Nnapulitano, Nedersaksisch, \u0928\u0947\u092a\u093e\u0932 \u092d\u093e\u0937\u093e, Nederlands, \u202aNorsk (nynorsk)\u202c, \u202aNorsk (bokm\u00e5l)\u202c, Nouormand, Din\u00e9 bizaad, Occitan, \u0418\u0440\u043e\u043d\u0430\u0443, Papiamentu, Deitsch, Norfuk \/ Pitkern, Polski, \u067e\u0646\u062c\u0627\u0628\u06cc, \u067e\u069a\u062a\u0648, Portugu\u00eas, Runa Simi, Rumantsch, Romani, Rom\u00e2n\u0103, \u0420\u0443\u0441\u0441\u043a\u0438\u0439, \u0421\u0430\u0445\u0430 \u0442\u044b\u043b\u0430, Sardu, Sicilianu, Scots, S\u00e1megiella, Simple English, Sloven\u010dina, Sloven\u0161\u010dina, \u0421\u0440\u043f\u0441\u043a\u0438 \/ Srpski, Seeltersk, Svenska, Kiswahili, \u0ba4\u0bae\u0bbf\u0bb4\u0bcd, \u0c24\u0c46\u0c32\u0c41\u0c17\u0c41, \u0422\u043e\u04b7\u0438\u043a\u04e3, \u0e44\u0e17\u0e22, T\u00fcrkmen\u00e7e, Tagalog, T\u00fcrk\u00e7e, \u0422\u0430\u0442\u0430\u0440\u0447\u0430\/Tatar\u00e7a, \u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430, \u0627\u0631\u062f\u0648, Ti\u1ebfng Vi\u1ec7t, Volap\u00fck, Walon, Winaray, \u5434\u8bed, isiXhosa, \u05d9\u05d9\u05b4\u05d3\u05d9\u05e9, Yor\u00f9b\u00e1, Ze\u00eauws, \u4e2d\u6587, B\u00e2n-l\u00e2m-g\u00fa, \u7cb5\u8a9e":"long key"}]}}';
567
568 self::$testArgsJSON['testSet'] = '{"1":{"set":["i32",3,1,5,6]}}';
569
570 self::$testArgsJSON['testList'] = '{"1":{"lst":["i32",3,1,2,3]}}';
571
572 self::$testArgsJSON['testEnum'] = '{"1":{"i32":1}}';
573
574 self::$testArgsJSON['testTypedef'] = '{"1":{"i64":69}}';
575
576 self::$testArgsJSON['testMapMap'] = '{"0":{"map":["i32","map",2,{"4":["i32","i32",4,{"1":1,"2":2,"3":3,"4":4}],"-4":["i32","i32",4,{"-4":-4,"-3":-3,"-2":-2,"-1":-1}]}]}}';
577
578 self::$testArgsJSON['testInsanity'] = '{"0":{"map":["i64","map",2,{"1":["i32","rec",2,{"2":{"1":{"map":["i32","i64",2,{"5":5,"8":8}]},"2":{"lst":["rec",2,{"1":{"str":"Goodbye4"},"4":{"i8":4},"9":{"i32":4},"11":{"i64":4}},{"1":{"str":"Hello2"},"4":{"i8":2},"9":{"i32":2},"11":{"i64":2}}]}},"3":{"1":{"map":["i32","i64",2,{"5":5,"8":8}]},"2":{"lst":["rec",2,{"1":{"str":"Goodbye4"},"4":{"i8":4},"9":{"i32":4},"11":{"i64":4}},{"1":{"str":"Hello2"},"4":{"i8":2},"9":{"i32":2},"11":{"i64":2}}]}}}],"2":["i32","rec",1,{"6":{}}]}]}}';
579
580 }
581}