| Roger Meier | 33b720a | 2012-01-24 18:42:46 +0000 | [diff] [blame] | 1 | <?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 |  | 
|  | 24 | define( 'BUFSIZ', 8192 ); //big enough to read biggest serialized Fixture arg. | 
|  | 25 |  | 
|  | 26 | $GLOBALS['THRIFT_ROOT'] = dirname(__FILE__) . '/../../src'; | 
|  | 27 |  | 
|  | 28 | require_once $GLOBALS['THRIFT_ROOT'] . '/Thrift.php'; | 
|  | 29 | require_once $GLOBALS['THRIFT_ROOT'] . '/TStringUtils.php'; | 
|  | 30 | require_once $GLOBALS['THRIFT_ROOT'] . '/protocol/TJSONProtocol.php'; | 
|  | 31 | require_once $GLOBALS['THRIFT_ROOT'] . '/transport/TMemoryBuffer.php'; | 
|  | 32 |  | 
|  | 33 | /*** | 
|  | 34 | * This test suite depends on running the compiler against the | 
|  | 35 | * standard ThriftTest.thrift file: | 
|  | 36 | * | 
|  | 37 | * lib/php/test$ ../../../compiler/cpp/thrift --gen php -r \ | 
|  | 38 | *   --out ../src/packages ../../../test/ThriftTest.thrift | 
|  | 39 | */ | 
|  | 40 | require_once $GLOBALS['THRIFT_ROOT'] . '/packages/ThriftTest/ThriftTest.php'; | 
|  | 41 |  | 
|  | 42 | require_once dirname(__FILE__) . '/../Fixtures.php'; | 
|  | 43 |  | 
|  | 44 | class TestTJSONProtocol extends PHPUnit_Framework_TestCase | 
|  | 45 | { | 
|  | 46 | private $transport; | 
|  | 47 | private $protocol; | 
|  | 48 |  | 
|  | 49 | public static function setUpBeforeClass() | 
|  | 50 | { | 
|  | 51 | Fixtures::populateTestArgs(); | 
|  | 52 | TestTJSONProtocol_Fixtures::populateTestArgsJSON(); | 
|  | 53 | } | 
|  | 54 |  | 
|  | 55 | public function setUp() | 
|  | 56 | { | 
|  | 57 | $this->transport = new TMemoryBuffer(); | 
|  | 58 | $this->protocol = new TJSONProtocol($this->transport); | 
|  | 59 | $this->transport->open(); | 
|  | 60 | } | 
|  | 61 |  | 
|  | 62 | /*** | 
|  | 63 | * WRITE TESTS | 
|  | 64 | */ | 
|  | 65 |  | 
|  | 66 | public function testVoid_Write() | 
|  | 67 | { | 
|  | 68 | $args = new ThriftTest_ThriftTest_testVoid_args(); | 
|  | 69 | $args->write( $this->protocol ); | 
|  | 70 |  | 
|  | 71 | $actual = $this->transport->read( BUFSIZ ); | 
|  | 72 | $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testVoid']; | 
|  | 73 |  | 
|  | 74 | $this->assertEquals( $expected, $actual ); | 
|  | 75 | } | 
|  | 76 |  | 
|  | 77 | public function testString1_Write() | 
|  | 78 | { | 
|  | 79 | $args = new ThriftTest_ThriftTest_testString_args(); | 
|  | 80 | $args->thing = Fixtures::$testArgs['testString1']; | 
|  | 81 | $args->write( $this->protocol ); | 
|  | 82 |  | 
|  | 83 | $actual = $this->transport->read( BUFSIZ ); | 
|  | 84 | $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testString1']; | 
|  | 85 |  | 
|  | 86 | #$this->assertEquals( $expected, $actual ); | 
|  | 87 | } | 
|  | 88 |  | 
|  | 89 | public function testString2_Write() | 
|  | 90 | { | 
|  | 91 | $args = new ThriftTest_ThriftTest_testString_args(); | 
|  | 92 | $args->thing = Fixtures::$testArgs['testString2']; | 
|  | 93 | $args->write( $this->protocol ); | 
|  | 94 |  | 
|  | 95 | $actual = $this->transport->read( BUFSIZ ); | 
|  | 96 | $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testString2']; | 
|  | 97 |  | 
|  | 98 | $this->assertEquals( $expected, $actual ); | 
|  | 99 | } | 
|  | 100 |  | 
|  | 101 | public function testDouble_Write() | 
|  | 102 | { | 
|  | 103 | $args = new ThriftTest_ThriftTest_testDouble_args(); | 
|  | 104 | $args->thing = Fixtures::$testArgs['testDouble']; | 
|  | 105 | $args->write( $this->protocol ); | 
|  | 106 |  | 
|  | 107 | $actual = $this->transport->read( BUFSIZ ); | 
|  | 108 | $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testDouble']; | 
|  | 109 |  | 
|  | 110 | $this->assertEquals( $expected, $actual ); | 
|  | 111 | } | 
|  | 112 |  | 
|  | 113 | public function testByte_Write() | 
|  | 114 | { | 
|  | 115 | $args = new ThriftTest_ThriftTest_testByte_args(); | 
|  | 116 | $args->thing = Fixtures::$testArgs['testByte']; | 
|  | 117 | $args->write( $this->protocol ); | 
|  | 118 |  | 
|  | 119 | $actual = $this->transport->read( BUFSIZ ); | 
|  | 120 | $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testByte']; | 
|  | 121 |  | 
|  | 122 | $this->assertEquals( $expected, $actual ); | 
|  | 123 | } | 
|  | 124 |  | 
|  | 125 | public function testI32_Write() | 
|  | 126 | { | 
|  | 127 | $args = new ThriftTest_ThriftTest_testI32_args(); | 
|  | 128 | $args->thing = Fixtures::$testArgs['testI32']; | 
|  | 129 | $args->write( $this->protocol ); | 
|  | 130 |  | 
|  | 131 | $actual = $this->transport->read( BUFSIZ ); | 
|  | 132 | $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testI32']; | 
|  | 133 |  | 
|  | 134 | $this->assertEquals( $expected, $actual ); | 
|  | 135 | } | 
|  | 136 |  | 
|  | 137 | public function testI64_Write() | 
|  | 138 | { | 
|  | 139 | $args = new ThriftTest_ThriftTest_testI64_args(); | 
|  | 140 | $args->thing = Fixtures::$testArgs['testI64']; | 
|  | 141 | $args->write( $this->protocol ); | 
|  | 142 |  | 
|  | 143 | $actual = $this->transport->read( BUFSIZ ); | 
|  | 144 | $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testI64']; | 
|  | 145 |  | 
|  | 146 | $this->assertEquals( $expected, $actual ); | 
|  | 147 | } | 
|  | 148 |  | 
|  | 149 | public function testStruct_Write() | 
|  | 150 | { | 
|  | 151 | $args = new ThriftTest_ThriftTest_testStruct_args(); | 
|  | 152 | $args->thing = Fixtures::$testArgs['testStruct']; | 
|  | 153 |  | 
|  | 154 | $args->write( $this->protocol ); | 
|  | 155 |  | 
|  | 156 | $actual = $this->transport->read( BUFSIZ ); | 
|  | 157 | $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testStruct']; | 
|  | 158 |  | 
|  | 159 | $this->assertEquals( $expected, $actual ); | 
|  | 160 | } | 
|  | 161 |  | 
|  | 162 | public function testNest_Write() | 
|  | 163 | { | 
|  | 164 | $args = new ThriftTest_ThriftTest_testNest_args(); | 
|  | 165 | $args->thing = Fixtures::$testArgs['testNest']; | 
|  | 166 |  | 
|  | 167 | $args->write( $this->protocol ); | 
|  | 168 |  | 
|  | 169 | $actual = $this->transport->read( BUFSIZ ); | 
|  | 170 | $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testNest']; | 
|  | 171 |  | 
|  | 172 | $this->assertEquals( $expected, $actual ); | 
|  | 173 | } | 
|  | 174 |  | 
|  | 175 | public function testMap_Write() | 
|  | 176 | { | 
|  | 177 | $args = new ThriftTest_ThriftTest_testMap_args(); | 
|  | 178 | $args->thing = Fixtures::$testArgs['testMap']; | 
|  | 179 |  | 
|  | 180 | $args->write( $this->protocol ); | 
|  | 181 |  | 
|  | 182 | $actual = $this->transport->read( BUFSIZ ); | 
|  | 183 | $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testMap']; | 
|  | 184 |  | 
|  | 185 | $this->assertEquals( $expected, $actual ); | 
|  | 186 | } | 
|  | 187 |  | 
|  | 188 | public function testStringMap_Write() | 
|  | 189 | { | 
|  | 190 | $args = new ThriftTest_ThriftTest_testStringMap_args(); | 
|  | 191 | $args->thing = Fixtures::$testArgs['testStringMap']; | 
|  | 192 |  | 
|  | 193 | $args->write( $this->protocol ); | 
|  | 194 |  | 
|  | 195 | $actual = $this->transport->read( BUFSIZ ); | 
|  | 196 | $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testStringMap']; | 
|  | 197 |  | 
|  | 198 | $this->assertEquals( $expected, $actual ); | 
|  | 199 | } | 
|  | 200 |  | 
|  | 201 | public function testSet_Write() | 
|  | 202 | { | 
|  | 203 | $args = new ThriftTest_ThriftTest_testSet_args(); | 
|  | 204 | $args->thing = Fixtures::$testArgs['testSet']; | 
|  | 205 |  | 
|  | 206 | $args->write( $this->protocol ); | 
|  | 207 |  | 
|  | 208 | $actual = $this->transport->read( BUFSIZ ); | 
|  | 209 | $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testSet']; | 
|  | 210 |  | 
|  | 211 | $this->assertEquals( $expected, $actual ); | 
|  | 212 | } | 
|  | 213 |  | 
|  | 214 | public function testList_Write() | 
|  | 215 | { | 
|  | 216 | $args = new ThriftTest_ThriftTest_testList_args(); | 
|  | 217 | $args->thing = Fixtures::$testArgs['testList']; | 
|  | 218 |  | 
|  | 219 | $args->write( $this->protocol ); | 
|  | 220 |  | 
|  | 221 | $actual = $this->transport->read( BUFSIZ ); | 
|  | 222 | $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testList']; | 
|  | 223 |  | 
|  | 224 | $this->assertEquals( $expected, $actual ); | 
|  | 225 | } | 
|  | 226 |  | 
|  | 227 | public function testEnum_Write() | 
|  | 228 | { | 
|  | 229 | $args = new ThriftTest_ThriftTest_testEnum_args(); | 
|  | 230 | $args->thing = Fixtures::$testArgs['testEnum']; | 
|  | 231 |  | 
|  | 232 | $args->write( $this->protocol ); | 
|  | 233 |  | 
|  | 234 | $actual = $this->transport->read( BUFSIZ ); | 
|  | 235 | $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testEnum']; | 
|  | 236 |  | 
|  | 237 | $this->assertEquals( $expected, $actual ); | 
|  | 238 | } | 
|  | 239 |  | 
|  | 240 | public function testTypedef_Write() | 
|  | 241 | { | 
|  | 242 | $args = new ThriftTest_ThriftTest_testTypedef_args(); | 
|  | 243 | $args->thing = Fixtures::$testArgs['testTypedef']; | 
|  | 244 |  | 
|  | 245 | $args->write( $this->protocol ); | 
|  | 246 |  | 
|  | 247 | $actual = $this->transport->read( BUFSIZ ); | 
|  | 248 | $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testTypedef']; | 
|  | 249 |  | 
|  | 250 | $this->assertEquals( $expected, $actual ); | 
|  | 251 | } | 
|  | 252 |  | 
|  | 253 | /*** | 
|  | 254 | * READ TESTS | 
|  | 255 | */ | 
|  | 256 |  | 
|  | 257 | public function testVoid_Read() | 
|  | 258 | { | 
|  | 259 | $this->transport->write( | 
|  | 260 | TestTJSONProtocol_Fixtures::$testArgsJSON['testVoid'] | 
|  | 261 | ); | 
|  | 262 | $args = new ThriftTest_ThriftTest_testVoid_args(); | 
|  | 263 | $args->read( $this->protocol ); | 
|  | 264 | } | 
|  | 265 |  | 
|  | 266 | public function testString1_Read() | 
|  | 267 | { | 
|  | 268 | $this->transport->write( | 
|  | 269 | TestTJSONProtocol_Fixtures::$testArgsJSON['testString1'] | 
|  | 270 | ); | 
|  | 271 | $args = new ThriftTest_ThriftTest_testString_args(); | 
|  | 272 | $args->read( $this->protocol ); | 
|  | 273 |  | 
|  | 274 | $actual = $args->thing; | 
|  | 275 | $expected = Fixtures::$testArgs['testString1']; | 
|  | 276 |  | 
|  | 277 | $this->assertEquals( $expected, $actual ); | 
|  | 278 | } | 
|  | 279 |  | 
|  | 280 | public function testString2_Read() | 
|  | 281 | { | 
|  | 282 | $this->transport->write( | 
|  | 283 | TestTJSONProtocol_Fixtures::$testArgsJSON['testString2'] | 
|  | 284 | ); | 
|  | 285 | $args = new ThriftTest_ThriftTest_testString_args(); | 
|  | 286 | $args->read( $this->protocol ); | 
|  | 287 |  | 
|  | 288 | $actual = $args->thing; | 
|  | 289 | $expected = Fixtures::$testArgs['testString2']; | 
|  | 290 |  | 
|  | 291 | $this->assertEquals( $expected, $actual ); | 
|  | 292 | } | 
|  | 293 |  | 
|  | 294 | public function testString3_Write() | 
|  | 295 | { | 
|  | 296 | $args = new ThriftTest_ThriftTest_testString_args(); | 
|  | 297 | $args->thing = Fixtures::$testArgs['testString3']; | 
|  | 298 | $args->write( $this->protocol ); | 
|  | 299 |  | 
|  | 300 | $actual = $this->transport->read( BUFSIZ ); | 
|  | 301 | $expected = TestTJSONProtocol_Fixtures::$testArgsJSON['testString3']; | 
|  | 302 |  | 
|  | 303 | $this->assertEquals( $expected, $actual ); | 
|  | 304 | } | 
|  | 305 |  | 
|  | 306 | public function testDouble_Read() | 
|  | 307 | { | 
|  | 308 | $this->transport->write( | 
|  | 309 | TestTJSONProtocol_Fixtures::$testArgsJSON['testDouble'] | 
|  | 310 | ); | 
|  | 311 | $args = new ThriftTest_ThriftTest_testDouble_args(); | 
|  | 312 | $args->read( $this->protocol ); | 
|  | 313 |  | 
|  | 314 | $actual = $args->thing; | 
|  | 315 | $expected = Fixtures::$testArgs['testDouble']; | 
|  | 316 |  | 
|  | 317 | $this->assertEquals( $expected, $actual ); | 
|  | 318 | } | 
|  | 319 |  | 
|  | 320 | public function testByte_Read() | 
|  | 321 | { | 
|  | 322 | $this->transport->write( | 
|  | 323 | TestTJSONProtocol_Fixtures::$testArgsJSON['testByte'] | 
|  | 324 | ); | 
|  | 325 | $args = new ThriftTest_ThriftTest_testByte_args(); | 
|  | 326 | $args->read( $this->protocol ); | 
|  | 327 |  | 
|  | 328 | $actual = $args->thing; | 
|  | 329 | $expected = Fixtures::$testArgs['testByte']; | 
|  | 330 |  | 
|  | 331 | $this->assertEquals( $expected, $actual ); | 
|  | 332 | } | 
|  | 333 |  | 
|  | 334 | public function testI32_Read() | 
|  | 335 | { | 
|  | 336 | $this->transport->write( | 
|  | 337 | TestTJSONProtocol_Fixtures::$testArgsJSON['testI32'] | 
|  | 338 | ); | 
|  | 339 | $args = new ThriftTest_ThriftTest_testI32_args(); | 
|  | 340 | $args->read( $this->protocol ); | 
|  | 341 |  | 
|  | 342 | $actual = $args->thing; | 
|  | 343 | $expected = Fixtures::$testArgs['testI32']; | 
|  | 344 |  | 
|  | 345 | $this->assertEquals( $expected, $actual ); | 
|  | 346 | } | 
|  | 347 |  | 
|  | 348 | public function testI64_Read() | 
|  | 349 | { | 
|  | 350 | $this->transport->write( | 
|  | 351 | TestTJSONProtocol_Fixtures::$testArgsJSON['testI64'] | 
|  | 352 | ); | 
|  | 353 | $args = new ThriftTest_ThriftTest_testI64_args(); | 
|  | 354 | $args->read( $this->protocol ); | 
|  | 355 |  | 
|  | 356 | $actual = $args->thing; | 
|  | 357 | $expected = Fixtures::$testArgs['testI64']; | 
|  | 358 |  | 
|  | 359 | $this->assertEquals( $expected, $actual ); | 
|  | 360 |  | 
|  | 361 | } | 
|  | 362 |  | 
|  | 363 | public function testStruct_Read() | 
|  | 364 | { | 
|  | 365 | $this->transport->write( | 
|  | 366 | TestTJSONProtocol_Fixtures::$testArgsJSON['testStruct'] | 
|  | 367 | ); | 
|  | 368 | $args = new ThriftTest_ThriftTest_testStruct_args(); | 
|  | 369 | $args->read( $this->protocol ); | 
|  | 370 |  | 
|  | 371 | $actual = $args->thing; | 
|  | 372 | $expected = Fixtures::$testArgs['testStruct']; | 
|  | 373 |  | 
|  | 374 | $this->assertEquals( $expected, $actual ); | 
|  | 375 |  | 
|  | 376 | } | 
|  | 377 |  | 
|  | 378 | public function testNest_Read() | 
|  | 379 | { | 
|  | 380 | $this->transport->write( | 
|  | 381 | TestTJSONProtocol_Fixtures::$testArgsJSON['testNest'] | 
|  | 382 | ); | 
|  | 383 | $args = new ThriftTest_ThriftTest_testNest_args(); | 
|  | 384 | $args->read( $this->protocol ); | 
|  | 385 |  | 
|  | 386 | $actual = $args->thing; | 
|  | 387 | $expected = Fixtures::$testArgs['testNest']; | 
|  | 388 |  | 
|  | 389 | $this->assertEquals( $expected, $actual ); | 
|  | 390 |  | 
|  | 391 | } | 
|  | 392 |  | 
|  | 393 | public function testMap_Read() | 
|  | 394 | { | 
|  | 395 | $this->transport->write( | 
|  | 396 | TestTJSONProtocol_Fixtures::$testArgsJSON['testMap'] | 
|  | 397 | ); | 
|  | 398 | $args = new ThriftTest_ThriftTest_testMap_args(); | 
|  | 399 | $args->read( $this->protocol ); | 
|  | 400 |  | 
|  | 401 | $actual = $args->thing; | 
|  | 402 | $expected = Fixtures::$testArgs['testMap']; | 
|  | 403 |  | 
|  | 404 | $this->assertEquals( $expected, $actual ); | 
|  | 405 |  | 
|  | 406 | } | 
|  | 407 |  | 
|  | 408 | public function testStringMap_Read() | 
|  | 409 | { | 
|  | 410 | $this->transport->write( | 
|  | 411 | TestTJSONProtocol_Fixtures::$testArgsJSON['testStringMap'] | 
|  | 412 | ); | 
|  | 413 | $args = new ThriftTest_ThriftTest_testStringMap_args(); | 
|  | 414 | $args->read( $this->protocol ); | 
|  | 415 |  | 
|  | 416 | $actual = $args->thing; | 
|  | 417 | $expected = Fixtures::$testArgs['testStringMap']; | 
|  | 418 |  | 
|  | 419 | $this->assertEquals( $expected, $actual ); | 
|  | 420 |  | 
|  | 421 | } | 
|  | 422 |  | 
|  | 423 | public function testSet_Read() | 
|  | 424 | { | 
|  | 425 | $this->transport->write( | 
|  | 426 | TestTJSONProtocol_Fixtures::$testArgsJSON['testSet'] | 
|  | 427 | ); | 
|  | 428 | $args = new ThriftTest_ThriftTest_testSet_args(); | 
|  | 429 | $args->read( $this->protocol ); | 
|  | 430 |  | 
|  | 431 | $actual = $args->thing; | 
|  | 432 | $expected = Fixtures::$testArgs['testSet']; | 
|  | 433 |  | 
|  | 434 | $this->assertEquals( $expected, $actual ); | 
|  | 435 |  | 
|  | 436 | } | 
|  | 437 |  | 
|  | 438 | public function testList_Read() | 
|  | 439 | { | 
|  | 440 | $this->transport->write( | 
|  | 441 | TestTJSONProtocol_Fixtures::$testArgsJSON['testList'] | 
|  | 442 | ); | 
|  | 443 | $args = new ThriftTest_ThriftTest_testList_args(); | 
|  | 444 | $args->read( $this->protocol ); | 
|  | 445 |  | 
|  | 446 | $actual = $args->thing; | 
|  | 447 | $expected = Fixtures::$testArgs['testList']; | 
|  | 448 |  | 
|  | 449 | $this->assertEquals( $expected, $actual ); | 
|  | 450 |  | 
|  | 451 | } | 
|  | 452 |  | 
|  | 453 | public function testEnum_Read() | 
|  | 454 | { | 
|  | 455 | $this->transport->write( | 
|  | 456 | TestTJSONProtocol_Fixtures::$testArgsJSON['testEnum'] | 
|  | 457 | ); | 
|  | 458 | $args = new ThriftTest_ThriftTest_testEnum_args(); | 
|  | 459 | $args->read( $this->protocol ); | 
|  | 460 |  | 
|  | 461 | $actual = $args->thing; | 
|  | 462 | $expected = Fixtures::$testArgs['testEnum']; | 
|  | 463 |  | 
|  | 464 | $this->assertEquals( $expected, $actual ); | 
|  | 465 |  | 
|  | 466 | } | 
|  | 467 |  | 
|  | 468 | public function testTypedef_Read() | 
|  | 469 | { | 
|  | 470 | $this->transport->write( | 
|  | 471 | TestTJSONProtocol_Fixtures::$testArgsJSON['testTypedef'] | 
|  | 472 | ); | 
|  | 473 | $args = new ThriftTest_ThriftTest_testTypedef_args(); | 
|  | 474 | $args->read( $this->protocol ); | 
|  | 475 |  | 
|  | 476 | $actual = $args->thing; | 
|  | 477 | $expected = Fixtures::$testArgs['testTypedef']; | 
|  | 478 |  | 
|  | 479 | $this->assertEquals( $expected, $actual ); | 
|  | 480 | } | 
|  | 481 |  | 
|  | 482 | public function testMapMap_Read() | 
|  | 483 | { | 
|  | 484 | $this->transport->write( | 
|  | 485 | TestTJSONProtocol_Fixtures::$testArgsJSON['testMapMap'] | 
|  | 486 | ); | 
|  | 487 | $result = new ThriftTest_ThriftTest_testMapMap_result(); | 
|  | 488 | $result->read( $this->protocol ); | 
|  | 489 |  | 
|  | 490 | $actual = $result->success; | 
|  | 491 | $expected = Fixtures::$testArgs['testMapMapExpectedResult']; | 
|  | 492 |  | 
|  | 493 | $this->assertEquals( $expected, $actual ); | 
|  | 494 | } | 
|  | 495 |  | 
|  | 496 | public function testInsanity_Read() | 
|  | 497 | { | 
|  | 498 | $this->transport->write( | 
|  | 499 | TestTJSONProtocol_Fixtures::$testArgsJSON['testInsanity'] | 
|  | 500 | ); | 
|  | 501 | $result = new ThriftTest_ThriftTest_testInsanity_result(); | 
|  | 502 | $result->read( $this->protocol ); | 
|  | 503 |  | 
|  | 504 | $actual = $result->success; | 
|  | 505 | $expected = Fixtures::$testArgs['testInsanityExpectedResult']; | 
|  | 506 |  | 
|  | 507 | $this->assertEquals( $expected, $actual ); | 
|  | 508 | } | 
|  | 509 |  | 
|  | 510 | } | 
|  | 511 |  | 
|  | 512 | class TestTJSONProtocol_Fixtures | 
|  | 513 | { | 
|  | 514 | public static $testArgsJSON = array(); | 
|  | 515 |  | 
|  | 516 | public static function populateTestArgsJSON() | 
|  | 517 | { | 
|  | 518 | self::$testArgsJSON['testVoid'] = '{}'; | 
|  | 519 |  | 
|  | 520 | 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"}}'; | 
|  | 521 |  | 
|  | 522 | 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: !@#$%&()(&%$#{}{}<><><"}}'; | 
|  | 523 |  | 
|  | 524 | self::$testArgsJSON['testString3'] = '{"1":{"str":"string that ends in double-backslash \\\\\\\\"}}'; | 
|  | 525 |  | 
|  | 526 | self::$testArgsJSON['testDouble'] = '{"1":{"dbl":3.1415926535898}}'; | 
|  | 527 |  | 
|  | 528 | self::$testArgsJSON['testByte'] = '{"1":{"i8":1}}'; | 
|  | 529 |  | 
|  | 530 | self::$testArgsJSON['testI32'] = '{"1":{"i32":1073741824}}'; | 
|  | 531 |  | 
|  | 532 | self::$testArgsJSON['testI64'] = '{"1":{"i64":1152921504606847000}}'; | 
|  | 533 |  | 
|  | 534 | self::$testArgsJSON['testStruct'] = '{"1":{"rec":{"1":{"str":"worked"},"4":{"i8":1},"9":{"i32":1073741824},"11":{"i64":1152921504606847000}}}}'; | 
|  | 535 |  | 
|  | 536 | 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}}}}'; | 
|  | 537 |  | 
|  | 538 | self::$testArgsJSON['testMap'] = '{"1":{"map":["i32","i32",3,{"7":77,"8":88,"9":99}]}}'; | 
|  | 539 |  | 
|  | 540 | 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"}]}}'; | 
|  | 541 |  | 
|  | 542 | self::$testArgsJSON['testSet'] = '{"1":{"set":["i32",3,1,5,6]}}'; | 
|  | 543 |  | 
|  | 544 | self::$testArgsJSON['testList'] = '{"1":{"lst":["i32",3,1,2,3]}}'; | 
|  | 545 |  | 
|  | 546 | self::$testArgsJSON['testEnum'] = '{"1":{"i32":1}}'; | 
|  | 547 |  | 
|  | 548 | self::$testArgsJSON['testTypedef'] = '{"1":{"i64":69}}'; | 
|  | 549 |  | 
|  | 550 | 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}]}]}}'; | 
|  | 551 |  | 
|  | 552 | 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":{}}]}]}}'; | 
|  | 553 |  | 
|  | 554 | } | 
|  | 555 | } |