blob: 1591027f4f3467e500f85a3452eb2118a56d94a2 [file] [log] [blame]
Bryan Duxburya971fb02011-03-04 00:49:40 +00001<?php
Roger Meier21c0a852012-09-05 19:47:14 +00002
3namespace test\php;
4
5require_once __DIR__.'/../../lib/php/lib/Thrift/ClassLoader/ThriftClassLoader.php';
6
7use Thrift\ClassLoader\ThriftClassLoader;
8
9if (!isset($GEN_DIR)) {
10 $GEN_DIR = 'gen-php';
11}
12if (!isset($MODE)) {
13 $MODE = 'normal';
14}
15
16$loader = new ThriftClassLoader();
17$loader->registerNamespace('Thrift', __DIR__ . '/../../lib/php/lib');
Andreas Schejad1ceba42016-05-15 21:49:04 +020018if ($GEN_DIR === 'gen-php-psr4') {
19 $loader->registerNamespace('ThriftTest', $GEN_DIR);
20} else {
21 $loader->registerDefinition('ThriftTest', $GEN_DIR);
22}
Roger Meier21c0a852012-09-05 19:47:14 +000023$loader->register();
24
David Reissea2cba82009-03-30 21:35:00 +000025/*
26 * Licensed to the Apache Software Foundation (ASF) under one
27 * or more contributor license agreements. See the NOTICE file
28 * distributed with this work for additional information
29 * regarding copyright ownership. The ASF licenses this file
30 * to you under the Apache License, Version 2.0 (the
31 * "License"); you may not use this file except in compliance
32 * with the License. You may obtain a copy of the License at
33 *
34 * http://www.apache.org/licenses/LICENSE-2.0
35 *
36 * Unless required by applicable law or agreed to in writing,
37 * software distributed under the License is distributed on an
38 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
39 * KIND, either express or implied. See the License for the
40 * specific language governing permissions and limitations
41 * under the License.
42 */
43
Mark Slee6e536442006-06-30 18:28:50 +000044/** Include the Thrift base */
Jim King5903d672015-06-29 18:12:48 -040045/** Include the protocols */
Roger Meier21c0a852012-09-05 19:47:14 +000046use Thrift\Protocol\TBinaryProtocol;
Håkon Hitlandf39d4c82016-11-17 16:18:03 +010047use Thrift\Protocol\TBinaryProtocolAccelerated;
Jim King5903d672015-06-29 18:12:48 -040048use Thrift\Protocol\TCompactProtocol;
49use Thrift\Protocol\TJSONProtocol;
Mark Slee6e536442006-06-30 18:28:50 +000050
51/** Include the socket layer */
Roger Meier21c0a852012-09-05 19:47:14 +000052use Thrift\Transport\TSocket;
53use Thrift\Transport\TSocketPool;
Mark Slee6e536442006-06-30 18:28:50 +000054
55/** Include the socket layer */
Roger Meier21c0a852012-09-05 19:47:14 +000056use Thrift\Transport\TFramedTransport;
57use Thrift\Transport\TBufferedTransport;
Mark Slee5b743072007-11-13 04:00:29 +000058
Jim King5903d672015-06-29 18:12:48 -040059function makeProtocol($transport, $PROTO)
60{
61 if ($PROTO == 'binary') {
62 return new TBinaryProtocol($transport);
63 } else if ($PROTO == 'compact') {
64 return new TCompactProtocol($transport);
65 } else if ($PROTO == 'json') {
66 return new TJSONProtocol($transport);
Håkon Hitlandf39d4c82016-11-17 16:18:03 +010067 } else if ($PROTO == 'accel') {
68 if (!function_exists('thrift_protocol_write_binary')) {
69 echo "Acceleration extension is not loaded\n";
70 exit(1);
71 }
72 return new TBinaryProtocolAccelerated($transport);
Jim King5903d672015-06-29 18:12:48 -040073 }
74
Håkon Hitlandf39d4c82016-11-17 16:18:03 +010075 echo "--protocol must be one of {binary|compact|json|accel}\n";
76 exit(1);
Jim King5903d672015-06-29 18:12:48 -040077}
78
Mark Slee6e536442006-06-30 18:28:50 +000079$host = 'localhost';
80$port = 9090;
81
82if ($argc > 1) {
83 $host = $argv[0];
84}
85
86if ($argc > 2) {
87 $host = $argv[1];
88}
89
Roger Meier41ad4342015-03-24 22:30:40 +010090foreach ($argv as $arg) {
91 if (substr($arg, 0, 7) == '--port=') {
92 $port = substr($arg, 7);
Jim King5903d672015-06-29 18:12:48 -040093 } else if (substr($arg, 0, 12) == '--transport=') {
94 $MODE = substr($arg, 12);
95 } else if (substr($arg, 0, 11) == '--protocol=') {
96 $PROTO = substr($arg, 11);
97 }
Roger Meier41ad4342015-03-24 22:30:40 +010098}
99
Mark Slee1dd819c2006-10-26 04:56:18 +0000100$hosts = array('localhost');
Mark Sleeade2c832006-09-08 03:41:50 +0000101
Mark Slee6e536442006-06-30 18:28:50 +0000102$socket = new TSocket($host, $port);
Mark Sleeade2c832006-09-08 03:41:50 +0000103$socket = new TSocketPool($hosts, $port);
104$socket->setDebug(TRUE);
Mark Slee6e536442006-06-30 18:28:50 +0000105
Mark Sleed3d733a2006-09-01 22:19:06 +0000106if ($MODE == 'inline') {
107 $transport = $socket;
Roger Meier21c0a852012-09-05 19:47:14 +0000108 $testClient = new \ThriftTest\ThriftTestClient($transport);
Bryan Duxburya971fb02011-03-04 00:49:40 +0000109} else if ($MODE == 'framed') {
110 $framedSocket = new TFramedTransport($socket);
111 $transport = $framedSocket;
Jim King5903d672015-06-29 18:12:48 -0400112 $protocol = makeProtocol($transport, $PROTO);
Roger Meier21c0a852012-09-05 19:47:14 +0000113 $testClient = new \ThriftTest\ThriftTestClient($protocol);
Mark Sleed3d733a2006-09-01 22:19:06 +0000114} else {
115 $bufferedSocket = new TBufferedTransport($socket, 1024, 1024);
116 $transport = $bufferedSocket;
Jim King5903d672015-06-29 18:12:48 -0400117 $protocol = makeProtocol($transport, $PROTO);
Roger Meier21c0a852012-09-05 19:47:14 +0000118 $testClient = new \ThriftTest\ThriftTestClient($protocol);
Mark Sleed3d733a2006-09-01 22:19:06 +0000119}
120
121$transport->open();
Mark Slee6e536442006-06-30 18:28:50 +0000122
123$start = microtime(true);
124
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100125define('ERR_BASETYPES', 1);
126define('ERR_STRUCTS', 2);
127define('ERR_CONTAINERS', 4);
128define('ERR_EXCEPTIONS', 8);
129define('ERR_UNKNOWN', 64);
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900130$exitcode = 0;
Mark Slee6e536442006-06-30 18:28:50 +0000131/**
132 * VOID TEST
133 */
134print_r("testVoid()");
135$testClient->testVoid();
136print_r(" = void\n");
137
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900138function roundtrip($testClient, $method, $value) {
139 global $exitcode;
140 print_r("$method($value)");
141 $ret = $testClient->$method($value);
142 print_r(" = \"$ret\"\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100143 if ($value !== $ret) {
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900144 print_r("*** FAILED ***\n");
145 $exitcode |= ERR_BASETYPES;
146 }
147}
148
Mark Slee6e536442006-06-30 18:28:50 +0000149/**
150 * STRING TEST
151 */
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900152roundtrip($testClient, 'testString', "Test");
Mark Slee5b743072007-11-13 04:00:29 +0000153
Mark Slee6e536442006-06-30 18:28:50 +0000154/**
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100155 * BOOL TEST
156 */
157roundtrip($testClient, 'testBool', true);
158roundtrip($testClient, 'testBool', false);
159
160/**
Mark Slee6e536442006-06-30 18:28:50 +0000161 * BYTE TEST
162 */
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900163roundtrip($testClient, 'testByte', 1);
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100164roundtrip($testClient, 'testByte', -1);
165roundtrip($testClient, 'testByte', 127);
166roundtrip($testClient, 'testByte', -128);
Mark Slee6e536442006-06-30 18:28:50 +0000167
168/**
169 * I32 TEST
170 */
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900171roundtrip($testClient, 'testI32', -1);
Mark Slee6e536442006-06-30 18:28:50 +0000172
173/**
174 * I64 TEST
175 */
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100176roundtrip($testClient, 'testI64', 0);
177roundtrip($testClient, 'testI64', 1);
178roundtrip($testClient, 'testI64', -1);
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900179roundtrip($testClient, 'testI64', -34359738368);
Mark Slee6e536442006-06-30 18:28:50 +0000180
181/**
Mark Sleec98d0502006-09-06 02:42:25 +0000182 * DOUBLE TEST
183 */
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900184roundtrip($testClient, 'testDouble', -852.234234234);
Mark Sleec98d0502006-09-06 02:42:25 +0000185
186/**
Jens Geyer8bcfdd92014-12-14 03:14:26 +0100187 * BINARY TEST -- TODO
188 */
189
190/**
Mark Slee6e536442006-06-30 18:28:50 +0000191 * STRUCT TEST
192 */
193print_r("testStruct({\"Zero\", 1, -3, -5})");
Roger Meier21c0a852012-09-05 19:47:14 +0000194$out = new \ThriftTest\Xtruct();
Mark Slee6e536442006-06-30 18:28:50 +0000195$out->string_thing = "Zero";
196$out->byte_thing = 1;
197$out->i32_thing = -3;
198$out->i64_thing = -5;
199$in = $testClient->testStruct($out);
200print_r(" = {\"".$in->string_thing."\", ".
201 $in->byte_thing.", ".
202 $in->i32_thing.", ".
203 $in->i64_thing."}\n");
204
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100205if ($in != $out) {
206 echo "**FAILED**\n";
207 $exitcode |= ERR_STRUCTS;
208}
209
Mark Slee6e536442006-06-30 18:28:50 +0000210/**
211 * NESTED STRUCT TEST
212 */
213print_r("testNest({1, {\"Zero\", 1, -3, -5}), 5}");
Roger Meier21c0a852012-09-05 19:47:14 +0000214$out2 = new \ThriftTest\Xtruct2();
Mark Slee6e536442006-06-30 18:28:50 +0000215$out2->byte_thing = 1;
216$out2->struct_thing = $out;
217$out2->i32_thing = 5;
218$in2 = $testClient->testNest($out2);
219$in = $in2->struct_thing;
220print_r(" = {".$in2->byte_thing.", {\"".
221 $in->string_thing."\", ".
222 $in->byte_thing.", ".
223 $in->i32_thing.", ".
224 $in->i64_thing."}, ".
225 $in2->i32_thing."}\n");
226
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100227if ($in2 != $out2) {
228 echo "**FAILED**\n";
229 $exitcode |= ERR_STRUCTS;
230}
231
Mark Slee6e536442006-06-30 18:28:50 +0000232/**
233 * MAP TEST
234 */
235$mapout = array();
236for ($i = 0; $i < 5; ++$i) {
237 $mapout[$i] = $i-10;
238}
239print_r("testMap({");
240$first = true;
241foreach ($mapout as $key => $val) {
242 if ($first) {
243 $first = false;
244 } else {
245 print_r(", ");
246 }
247 print_r("$key => $val");
248}
249print_r("})");
250
251$mapin = $testClient->testMap($mapout);
252print_r(" = {");
253$first = true;
254foreach ($mapin as $key => $val) {
255 if ($first) {
256 $first = false;
257 } else {
258 print_r(", ");
259 }
260 print_r("$key => $val");
261}
262print_r("}\n");
263
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100264if ($mapin != $mapout) {
265 echo "**FAILED**\n";
266 $exitcode |= ERR_CONTAINERS;
267}
268
Håkon Hitlande66b8fc2016-12-05 18:42:41 +0100269$mapout = array();
270for ($i = 0; $i < 10; $i++) {
271 $mapout["key$i"] = "val$i";
272}
273print_r('testStringMap({');
274$first = true;
275foreach ($mapout as $key => $val) {
276 if ($first) {
277 $first = false;
278 } else {
279 print_r(", ");
280 }
281 print_r("\"$key\" => \"$val\"");
282}
283print_r("})");
284$mapin = $testClient->testStringMap($mapout);
285print_r(" = {");
286$first = true;
287foreach ($mapin as $key => $val) {
288 if ($first) {
289 $first = false;
290 } else {
291 print_r(", ");
292 }
293 print_r("\"$key\" => \"$val\"");
294}
295print_r("}\n");
296ksort($mapin);
297if ($mapin != $mapout) {
298 echo "**FAILED**\n";
299 $exitcode |= ERR_CONTAINERS;
300}
301
Mark Slee6e536442006-06-30 18:28:50 +0000302/**
303 * SET TEST
304 */
305$setout = array();;
306for ($i = -2; $i < 3; ++$i) {
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100307 $setout[$i]= true;
Mark Slee6e536442006-06-30 18:28:50 +0000308}
309print_r("testSet({");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100310echo implode(',', array_keys($setout));
Mark Slee6e536442006-06-30 18:28:50 +0000311print_r("})");
312$setin = $testClient->testSet($setout);
313print_r(" = {");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100314echo implode(', ', array_keys($setin));
Mark Slee6e536442006-06-30 18:28:50 +0000315print_r("}\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100316// Order of keys in set does not matter
317ksort($setin);
318if ($setout !== $setin) {
319 echo "**FAILED**\n";
320 $exitcode |= ERR_CONTAINERS;
321}
322// Regression test for corrupted array
323if ($setin[2] !== $setout[2] || is_int($setin[2])) {
324 echo "**FAILED**\n";
325 $exitcode |= ERR_CONTAINERS;
326}
Mark Slee6e536442006-06-30 18:28:50 +0000327
328/**
329 * LIST TEST
330 */
331$listout = array();
332for ($i = -2; $i < 3; ++$i) {
333 $listout []= $i;
334}
335print_r("testList({");
336$first = true;
337foreach ($listout as $val) {
338 if ($first) {
339 $first = false;
340 } else {
341 print_r(", ");
342 }
343 print_r($val);
344}
345print_r("})");
346$listin = $testClient->testList($listout);
347print_r(" = {");
348$first = true;
349foreach ($listin as $val) {
350 if ($first) {
351 $first = false;
352 } else {
353 print_r(", ");
354 }
355 print_r($val);
356}
357print_r("}\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100358if ($listin !== $listout) {
359 echo "**FAILED**\n";
360 $exitcode |= ERR_CONTAINERS;
361}
Mark Slee6e536442006-06-30 18:28:50 +0000362
363/**
364 * ENUM TEST
365 */
366print_r("testEnum(ONE)");
Roger Meier87afaac2013-01-06 20:10:42 +0100367$ret = $testClient->testEnum(\ThriftTest\Numberz::ONE);
Mark Slee6e536442006-06-30 18:28:50 +0000368print_r(" = $ret\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100369if ($ret != \ThriftTest\Numberz::ONE) {
370 echo "**FAILED**\n";
371 $exitcode |= ERR_STRUCTS;
372}
Mark Slee6e536442006-06-30 18:28:50 +0000373
374print_r("testEnum(TWO)");
Roger Meier87afaac2013-01-06 20:10:42 +0100375$ret = $testClient->testEnum(\ThriftTest\Numberz::TWO);
Mark Slee6e536442006-06-30 18:28:50 +0000376print_r(" = $ret\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100377if ($ret != \ThriftTest\Numberz::TWO) {
378 echo "**FAILED**\n";
379 $exitcode |= ERR_STRUCTS;
380}
Mark Slee6e536442006-06-30 18:28:50 +0000381
382print_r("testEnum(THREE)");
Roger Meier87afaac2013-01-06 20:10:42 +0100383$ret = $testClient->testEnum(\ThriftTest\Numberz::THREE);
Mark Slee6e536442006-06-30 18:28:50 +0000384print_r(" = $ret\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100385if ($ret != \ThriftTest\Numberz::THREE) {
386 echo "**FAILED**\n";
387 $exitcode |= ERR_STRUCTS;
388}
Mark Slee6e536442006-06-30 18:28:50 +0000389
390print_r("testEnum(FIVE)");
Roger Meier87afaac2013-01-06 20:10:42 +0100391$ret = $testClient->testEnum(\ThriftTest\Numberz::FIVE);
Mark Slee6e536442006-06-30 18:28:50 +0000392print_r(" = $ret\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100393if ($ret != \ThriftTest\Numberz::FIVE) {
394 echo "**FAILED**\n";
395 $exitcode |= ERR_STRUCTS;
396}
Mark Slee6e536442006-06-30 18:28:50 +0000397
398print_r("testEnum(EIGHT)");
Roger Meier87afaac2013-01-06 20:10:42 +0100399$ret = $testClient->testEnum(\ThriftTest\Numberz::EIGHT);
Mark Slee6e536442006-06-30 18:28:50 +0000400print_r(" = $ret\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100401if ($ret != \ThriftTest\Numberz::EIGHT) {
402 echo "**FAILED**\n";
403 $exitcode |= ERR_STRUCTS;
404}
Mark Slee6e536442006-06-30 18:28:50 +0000405
406/**
407 * TYPEDEF TEST
408 */
409print_r("testTypedef(309858235082523)");
410$uid = $testClient->testTypedef(309858235082523);
411print_r(" = $uid\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100412if ($uid !== 309858235082523) {
413 echo "**FAILED**\n";
414 $exitcode |= ERR_STRUCTS;
415}
Mark Slee6e536442006-06-30 18:28:50 +0000416
417/**
418 * NESTED MAP TEST
419 */
420print_r("testMapMap(1)");
421$mm = $testClient->testMapMap(1);
422print_r(" = {");
423foreach ($mm as $key => $val) {
424 print_r("$key => {");
425 foreach ($val as $k2 => $v2) {
426 print_r("$k2 => $v2, ");
427 }
428 print_r("}, ");
429}
430print_r("}\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100431$expected_mm = [
432 -4 => [-4 => -4, -3 => -3, -2 => -2, -1 => -1],
433 4 => [4 => 4, 3 => 3, 2 => 2, 1 => 1],
434];
435if ($mm != $expected_mm) {
436 echo "**FAILED**\n";
437 $exitcode |= ERR_CONTAINERS;
438}
Mark Slee6e536442006-06-30 18:28:50 +0000439
440/**
441 * INSANITY TEST
442 */
Roger Meier21c0a852012-09-05 19:47:14 +0000443$insane = new \ThriftTest\Insanity();
Roger Meier87afaac2013-01-06 20:10:42 +0100444$insane->userMap[\ThriftTest\Numberz::FIVE] = 5000;
Roger Meier21c0a852012-09-05 19:47:14 +0000445$truck = new \ThriftTest\Xtruct();
Mark Slee6e536442006-06-30 18:28:50 +0000446$truck->string_thing = "Truck";
447$truck->byte_thing = 8;
448$truck->i32_thing = 8;
449$truck->i64_thing = 8;
450$insane->xtructs []= $truck;
451print_r("testInsanity()");
452$whoa = $testClient->testInsanity($insane);
453print_r(" = {");
454foreach ($whoa as $key => $val) {
455 print_r("$key => {");
456 foreach ($val as $k2 => $v2) {
457 print_r("$k2 => {");
458 $userMap = $v2->userMap;
459 print_r("{");
Bryan Duxburya971fb02011-03-04 00:49:40 +0000460 if (is_array($userMap)) {
Mark Sleed3d733a2006-09-01 22:19:06 +0000461 foreach ($userMap as $k3 => $v3) {
462 print_r("$k3 => $v3, ");
463 }
Mark Slee6e536442006-06-30 18:28:50 +0000464 }
465 print_r("}, ");
Mark Slee5b743072007-11-13 04:00:29 +0000466
Mark Slee6e536442006-06-30 18:28:50 +0000467 $xtructs = $v2->xtructs;
468 print_r("{");
Mark Sleed3d733a2006-09-01 22:19:06 +0000469 if (is_array($xtructs)) {
470 foreach ($xtructs as $x) {
471 print_r("{\"".$x->string_thing."\", ".
472 $x->byte_thing.", ".$x->i32_thing.", ".$x->i64_thing."}, ");
473 }
Mark Slee6e536442006-06-30 18:28:50 +0000474 }
475 print_r("}");
Mark Slee5b743072007-11-13 04:00:29 +0000476
Mark Slee6e536442006-06-30 18:28:50 +0000477 print_r("}, ");
478 }
479 print_r("}, ");
480}
481print_r("}\n");
482
Mark Sleed3d733a2006-09-01 22:19:06 +0000483/**
484 * EXCEPTION TEST
485 */
486print_r("testException('Xception')");
487try {
488 $testClient->testException('Xception');
489 print_r(" void\nFAILURE\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100490 $exitcode |= ERR_EXCEPTIONS;
Roger Meier87afaac2013-01-06 20:10:42 +0100491} catch (\ThriftTest\Xception $x) {
Mark Sleed3d733a2006-09-01 22:19:06 +0000492 print_r(' caught xception '.$x->errorCode.': '.$x->message."\n");
493}
494
Roy Sindre Norangsholec64f232017-07-26 20:49:38 +0200495// Regression test for THRIFT-4263
496print_r("testBinarySerializer_Deserialize('foo')");
497try {
498 \Thrift\Serializer\TBinarySerializer::deserialize(base64_decode('foo'), \ThriftTest\Xtruct2::class);
499 echo "**FAILED**\n";
500 $exitcode |= ERR_STRUCTS;
501} catch (\Thrift\Exception\TTransportException $happy_exception) {
502 // We expected this due to binary data of base64_decode('foo') is less then 4
503 // bytes and it tries to find thrift version number in the transport by
504 // reading i32() at the beginning. Casting to string validates that
505 // exception is still accessible in memory and not corrupted. Without patch,
506 // PHP will error log that the exception doesn't have any tostring method,
507 // which is a lie due to corrupted memory.
508 for($i=99; $i > 0; $i--) {
509 (string)$happy_exception;
510 }
511 print_r(" SUCCESS\n");
512}
513
Mark Slee6e536442006-06-30 18:28:50 +0000514/**
515 * Normal tests done.
516 */
517
518$stop = microtime(true);
519$elp = round(1000*($stop - $start), 0);
520print_r("Total time: $elp ms\n");
521
522/**
523 * Extraneous "I don't trust PHP to pack/unpack integer" tests
524 */
525
Håkon Hitlande66b8fc2016-12-05 18:42:41 +0100526if ($protocol instanceof TBinaryProtocolAccelerated) {
527 // Regression check: check that method name is not double-freed
528 // Method name should not be an interned string.
529 $method_name = "Void";
530 $method_name = "test$method_name";
531
532 $seqid = 0;
533 $args = new \ThriftTest\ThriftTest_testVoid_args();
534 thrift_protocol_write_binary($protocol, $method_name, \Thrift\Type\TMessageType::CALL, $args, $seqid, $protocol->isStrictWrite());
535 $testClient->recv_testVoid();
536
537}
538
Mark Slee6e536442006-06-30 18:28:50 +0000539// Max I32
540$num = pow(2, 30) + (pow(2, 30) - 1);
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100541roundtrip($testClient, 'testI32', $num);
Mark Slee6e536442006-06-30 18:28:50 +0000542
543// Min I32
544$num = 0 - pow(2, 31);
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100545roundtrip($testClient, 'testI32', $num);
Mark Slee6e536442006-06-30 18:28:50 +0000546
547// Max I64
548$num = pow(2, 62) + (pow(2, 62) - 1);
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100549roundtrip($testClient, 'testI64', $num);
Mark Slee6e536442006-06-30 18:28:50 +0000550
551// Min I64
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900552$num = 0 - pow(2, 62) - pow(2, 62);
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100553roundtrip($testClient, 'testI64', $num);
Mark Slee6e536442006-06-30 18:28:50 +0000554
Mark Sleed3d733a2006-09-01 22:19:06 +0000555$transport->close();
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900556exit($exitcode);