blob: aa42e09d33f74a940a03752775d1dbec18999166 [file] [log] [blame]
Bryan Duxburya971fb02011-03-04 00:49:40 +00001<?php
Roger Meier21c0a852012-09-05 19:47:14 +00002
3namespace test\php;
4
Robert Lua15060a2017-12-28 15:29:39 +08005require_once __DIR__.'/../../vendor/autoload.php';
Roger Meier21c0a852012-09-05 19:47:14 +00006
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();
Andreas Schejad1ceba42016-05-15 21:49:04 +020017if ($GEN_DIR === 'gen-php-psr4') {
18 $loader->registerNamespace('ThriftTest', $GEN_DIR);
19} else {
20 $loader->registerDefinition('ThriftTest', $GEN_DIR);
21}
Roger Meier21c0a852012-09-05 19:47:14 +000022$loader->register();
23
David Reissea2cba82009-03-30 21:35:00 +000024/*
25 * Licensed to the Apache Software Foundation (ASF) under one
26 * or more contributor license agreements. See the NOTICE file
27 * distributed with this work for additional information
28 * regarding copyright ownership. The ASF licenses this file
29 * to you under the Apache License, Version 2.0 (the
30 * "License"); you may not use this file except in compliance
31 * with the License. You may obtain a copy of the License at
32 *
33 * http://www.apache.org/licenses/LICENSE-2.0
34 *
35 * Unless required by applicable law or agreed to in writing,
36 * software distributed under the License is distributed on an
37 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
38 * KIND, either express or implied. See the License for the
39 * specific language governing permissions and limitations
40 * under the License.
41 */
42
Mark Slee6e536442006-06-30 18:28:50 +000043/** Include the Thrift base */
Jim King5903d672015-06-29 18:12:48 -040044/** Include the protocols */
Roger Meier21c0a852012-09-05 19:47:14 +000045use Thrift\Protocol\TBinaryProtocol;
Håkon Hitlandf39d4c82016-11-17 16:18:03 +010046use Thrift\Protocol\TBinaryProtocolAccelerated;
Jim King5903d672015-06-29 18:12:48 -040047use Thrift\Protocol\TCompactProtocol;
48use Thrift\Protocol\TJSONProtocol;
Mark Slee6e536442006-06-30 18:28:50 +000049
50/** Include the socket layer */
Roger Meier21c0a852012-09-05 19:47:14 +000051use Thrift\Transport\TSocket;
52use Thrift\Transport\TSocketPool;
Mark Slee6e536442006-06-30 18:28:50 +000053
54/** Include the socket layer */
Roger Meier21c0a852012-09-05 19:47:14 +000055use Thrift\Transport\TFramedTransport;
56use Thrift\Transport\TBufferedTransport;
Mark Slee5b743072007-11-13 04:00:29 +000057
Jim King5903d672015-06-29 18:12:48 -040058function makeProtocol($transport, $PROTO)
59{
60 if ($PROTO == 'binary') {
61 return new TBinaryProtocol($transport);
62 } else if ($PROTO == 'compact') {
63 return new TCompactProtocol($transport);
64 } else if ($PROTO == 'json') {
65 return new TJSONProtocol($transport);
Håkon Hitlandf39d4c82016-11-17 16:18:03 +010066 } else if ($PROTO == 'accel') {
67 if (!function_exists('thrift_protocol_write_binary')) {
68 echo "Acceleration extension is not loaded\n";
69 exit(1);
70 }
71 return new TBinaryProtocolAccelerated($transport);
Jim King5903d672015-06-29 18:12:48 -040072 }
73
Håkon Hitlandf39d4c82016-11-17 16:18:03 +010074 echo "--protocol must be one of {binary|compact|json|accel}\n";
75 exit(1);
Jim King5903d672015-06-29 18:12:48 -040076}
77
Mark Slee6e536442006-06-30 18:28:50 +000078$host = 'localhost';
79$port = 9090;
80
81if ($argc > 1) {
82 $host = $argv[0];
83}
84
85if ($argc > 2) {
86 $host = $argv[1];
87}
88
Roger Meier41ad4342015-03-24 22:30:40 +010089foreach ($argv as $arg) {
90 if (substr($arg, 0, 7) == '--port=') {
91 $port = substr($arg, 7);
Jim King5903d672015-06-29 18:12:48 -040092 } else if (substr($arg, 0, 12) == '--transport=') {
93 $MODE = substr($arg, 12);
94 } else if (substr($arg, 0, 11) == '--protocol=') {
95 $PROTO = substr($arg, 11);
96 }
Roger Meier41ad4342015-03-24 22:30:40 +010097}
98
Mark Slee1dd819c2006-10-26 04:56:18 +000099$hosts = array('localhost');
Mark Sleeade2c832006-09-08 03:41:50 +0000100
Mark Slee6e536442006-06-30 18:28:50 +0000101$socket = new TSocket($host, $port);
Mark Sleeade2c832006-09-08 03:41:50 +0000102$socket = new TSocketPool($hosts, $port);
103$socket->setDebug(TRUE);
Mark Slee6e536442006-06-30 18:28:50 +0000104
Mark Sleed3d733a2006-09-01 22:19:06 +0000105if ($MODE == 'inline') {
106 $transport = $socket;
Roger Meier21c0a852012-09-05 19:47:14 +0000107 $testClient = new \ThriftTest\ThriftTestClient($transport);
Bryan Duxburya971fb02011-03-04 00:49:40 +0000108} else if ($MODE == 'framed') {
109 $framedSocket = new TFramedTransport($socket);
110 $transport = $framedSocket;
Jim King5903d672015-06-29 18:12:48 -0400111 $protocol = makeProtocol($transport, $PROTO);
Roger Meier21c0a852012-09-05 19:47:14 +0000112 $testClient = new \ThriftTest\ThriftTestClient($protocol);
Mark Sleed3d733a2006-09-01 22:19:06 +0000113} else {
114 $bufferedSocket = new TBufferedTransport($socket, 1024, 1024);
115 $transport = $bufferedSocket;
Jim King5903d672015-06-29 18:12:48 -0400116 $protocol = makeProtocol($transport, $PROTO);
Roger Meier21c0a852012-09-05 19:47:14 +0000117 $testClient = new \ThriftTest\ThriftTestClient($protocol);
Mark Sleed3d733a2006-09-01 22:19:06 +0000118}
119
120$transport->open();
Mark Slee6e536442006-06-30 18:28:50 +0000121
122$start = microtime(true);
123
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100124define('ERR_BASETYPES', 1);
125define('ERR_STRUCTS', 2);
126define('ERR_CONTAINERS', 4);
127define('ERR_EXCEPTIONS', 8);
128define('ERR_UNKNOWN', 64);
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900129$exitcode = 0;
Mark Slee6e536442006-06-30 18:28:50 +0000130/**
131 * VOID TEST
132 */
133print_r("testVoid()");
134$testClient->testVoid();
135print_r(" = void\n");
136
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900137function roundtrip($testClient, $method, $value) {
138 global $exitcode;
139 print_r("$method($value)");
140 $ret = $testClient->$method($value);
141 print_r(" = \"$ret\"\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100142 if ($value !== $ret) {
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900143 print_r("*** FAILED ***\n");
144 $exitcode |= ERR_BASETYPES;
145 }
146}
147
Mark Slee6e536442006-06-30 18:28:50 +0000148/**
149 * STRING TEST
150 */
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900151roundtrip($testClient, 'testString', "Test");
Mark Slee5b743072007-11-13 04:00:29 +0000152
Mark Slee6e536442006-06-30 18:28:50 +0000153/**
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100154 * BOOL TEST
155 */
156roundtrip($testClient, 'testBool', true);
157roundtrip($testClient, 'testBool', false);
158
159/**
Mark Slee6e536442006-06-30 18:28:50 +0000160 * BYTE TEST
161 */
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900162roundtrip($testClient, 'testByte', 1);
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100163roundtrip($testClient, 'testByte', -1);
164roundtrip($testClient, 'testByte', 127);
165roundtrip($testClient, 'testByte', -128);
Mark Slee6e536442006-06-30 18:28:50 +0000166
167/**
168 * I32 TEST
169 */
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900170roundtrip($testClient, 'testI32', -1);
Mark Slee6e536442006-06-30 18:28:50 +0000171
172/**
173 * I64 TEST
174 */
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100175roundtrip($testClient, 'testI64', 0);
176roundtrip($testClient, 'testI64', 1);
177roundtrip($testClient, 'testI64', -1);
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900178roundtrip($testClient, 'testI64', -34359738368);
Mark Slee6e536442006-06-30 18:28:50 +0000179
180/**
Mark Sleec98d0502006-09-06 02:42:25 +0000181 * DOUBLE TEST
182 */
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900183roundtrip($testClient, 'testDouble', -852.234234234);
Mark Sleec98d0502006-09-06 02:42:25 +0000184
185/**
Jens Geyer8bcfdd92014-12-14 03:14:26 +0100186 * BINARY TEST -- TODO
187 */
188
189/**
Mark Slee6e536442006-06-30 18:28:50 +0000190 * STRUCT TEST
191 */
192print_r("testStruct({\"Zero\", 1, -3, -5})");
Roger Meier21c0a852012-09-05 19:47:14 +0000193$out = new \ThriftTest\Xtruct();
Mark Slee6e536442006-06-30 18:28:50 +0000194$out->string_thing = "Zero";
195$out->byte_thing = 1;
196$out->i32_thing = -3;
197$out->i64_thing = -5;
198$in = $testClient->testStruct($out);
199print_r(" = {\"".$in->string_thing."\", ".
200 $in->byte_thing.", ".
201 $in->i32_thing.", ".
202 $in->i64_thing."}\n");
203
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100204if ($in != $out) {
205 echo "**FAILED**\n";
206 $exitcode |= ERR_STRUCTS;
207}
208
Mark Slee6e536442006-06-30 18:28:50 +0000209/**
210 * NESTED STRUCT TEST
211 */
212print_r("testNest({1, {\"Zero\", 1, -3, -5}), 5}");
Roger Meier21c0a852012-09-05 19:47:14 +0000213$out2 = new \ThriftTest\Xtruct2();
Mark Slee6e536442006-06-30 18:28:50 +0000214$out2->byte_thing = 1;
215$out2->struct_thing = $out;
216$out2->i32_thing = 5;
217$in2 = $testClient->testNest($out2);
218$in = $in2->struct_thing;
219print_r(" = {".$in2->byte_thing.", {\"".
220 $in->string_thing."\", ".
221 $in->byte_thing.", ".
222 $in->i32_thing.", ".
223 $in->i64_thing."}, ".
224 $in2->i32_thing."}\n");
225
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100226if ($in2 != $out2) {
227 echo "**FAILED**\n";
228 $exitcode |= ERR_STRUCTS;
229}
230
Mark Slee6e536442006-06-30 18:28:50 +0000231/**
232 * MAP TEST
233 */
234$mapout = array();
235for ($i = 0; $i < 5; ++$i) {
236 $mapout[$i] = $i-10;
237}
238print_r("testMap({");
239$first = true;
240foreach ($mapout as $key => $val) {
241 if ($first) {
242 $first = false;
243 } else {
244 print_r(", ");
245 }
246 print_r("$key => $val");
247}
248print_r("})");
249
250$mapin = $testClient->testMap($mapout);
251print_r(" = {");
252$first = true;
253foreach ($mapin as $key => $val) {
254 if ($first) {
255 $first = false;
256 } else {
257 print_r(", ");
258 }
259 print_r("$key => $val");
260}
261print_r("}\n");
262
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100263if ($mapin != $mapout) {
264 echo "**FAILED**\n";
265 $exitcode |= ERR_CONTAINERS;
266}
267
Håkon Hitlande66b8fc2016-12-05 18:42:41 +0100268$mapout = array();
269for ($i = 0; $i < 10; $i++) {
270 $mapout["key$i"] = "val$i";
271}
272print_r('testStringMap({');
273$first = true;
274foreach ($mapout as $key => $val) {
275 if ($first) {
276 $first = false;
277 } else {
278 print_r(", ");
279 }
280 print_r("\"$key\" => \"$val\"");
281}
282print_r("})");
283$mapin = $testClient->testStringMap($mapout);
284print_r(" = {");
285$first = true;
286foreach ($mapin as $key => $val) {
287 if ($first) {
288 $first = false;
289 } else {
290 print_r(", ");
291 }
292 print_r("\"$key\" => \"$val\"");
293}
294print_r("}\n");
295ksort($mapin);
296if ($mapin != $mapout) {
297 echo "**FAILED**\n";
298 $exitcode |= ERR_CONTAINERS;
299}
300
Mark Slee6e536442006-06-30 18:28:50 +0000301/**
302 * SET TEST
303 */
304$setout = array();;
305for ($i = -2; $i < 3; ++$i) {
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100306 $setout[$i]= true;
Mark Slee6e536442006-06-30 18:28:50 +0000307}
308print_r("testSet({");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100309echo implode(',', array_keys($setout));
Mark Slee6e536442006-06-30 18:28:50 +0000310print_r("})");
311$setin = $testClient->testSet($setout);
312print_r(" = {");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100313echo implode(', ', array_keys($setin));
Mark Slee6e536442006-06-30 18:28:50 +0000314print_r("}\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100315// Order of keys in set does not matter
316ksort($setin);
317if ($setout !== $setin) {
318 echo "**FAILED**\n";
319 $exitcode |= ERR_CONTAINERS;
320}
321// Regression test for corrupted array
322if ($setin[2] !== $setout[2] || is_int($setin[2])) {
323 echo "**FAILED**\n";
324 $exitcode |= ERR_CONTAINERS;
325}
Mark Slee6e536442006-06-30 18:28:50 +0000326
327/**
328 * LIST TEST
329 */
330$listout = array();
331for ($i = -2; $i < 3; ++$i) {
332 $listout []= $i;
333}
334print_r("testList({");
335$first = true;
336foreach ($listout as $val) {
337 if ($first) {
338 $first = false;
339 } else {
340 print_r(", ");
341 }
342 print_r($val);
343}
344print_r("})");
345$listin = $testClient->testList($listout);
346print_r(" = {");
347$first = true;
348foreach ($listin as $val) {
349 if ($first) {
350 $first = false;
351 } else {
352 print_r(", ");
353 }
354 print_r($val);
355}
356print_r("}\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100357if ($listin !== $listout) {
358 echo "**FAILED**\n";
359 $exitcode |= ERR_CONTAINERS;
360}
Mark Slee6e536442006-06-30 18:28:50 +0000361
362/**
363 * ENUM TEST
364 */
365print_r("testEnum(ONE)");
Roger Meier87afaac2013-01-06 20:10:42 +0100366$ret = $testClient->testEnum(\ThriftTest\Numberz::ONE);
Mark Slee6e536442006-06-30 18:28:50 +0000367print_r(" = $ret\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100368if ($ret != \ThriftTest\Numberz::ONE) {
369 echo "**FAILED**\n";
370 $exitcode |= ERR_STRUCTS;
371}
Mark Slee6e536442006-06-30 18:28:50 +0000372
373print_r("testEnum(TWO)");
Roger Meier87afaac2013-01-06 20:10:42 +0100374$ret = $testClient->testEnum(\ThriftTest\Numberz::TWO);
Mark Slee6e536442006-06-30 18:28:50 +0000375print_r(" = $ret\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100376if ($ret != \ThriftTest\Numberz::TWO) {
377 echo "**FAILED**\n";
378 $exitcode |= ERR_STRUCTS;
379}
Mark Slee6e536442006-06-30 18:28:50 +0000380
381print_r("testEnum(THREE)");
Roger Meier87afaac2013-01-06 20:10:42 +0100382$ret = $testClient->testEnum(\ThriftTest\Numberz::THREE);
Mark Slee6e536442006-06-30 18:28:50 +0000383print_r(" = $ret\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100384if ($ret != \ThriftTest\Numberz::THREE) {
385 echo "**FAILED**\n";
386 $exitcode |= ERR_STRUCTS;
387}
Mark Slee6e536442006-06-30 18:28:50 +0000388
389print_r("testEnum(FIVE)");
Roger Meier87afaac2013-01-06 20:10:42 +0100390$ret = $testClient->testEnum(\ThriftTest\Numberz::FIVE);
Mark Slee6e536442006-06-30 18:28:50 +0000391print_r(" = $ret\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100392if ($ret != \ThriftTest\Numberz::FIVE) {
393 echo "**FAILED**\n";
394 $exitcode |= ERR_STRUCTS;
395}
Mark Slee6e536442006-06-30 18:28:50 +0000396
397print_r("testEnum(EIGHT)");
Roger Meier87afaac2013-01-06 20:10:42 +0100398$ret = $testClient->testEnum(\ThriftTest\Numberz::EIGHT);
Mark Slee6e536442006-06-30 18:28:50 +0000399print_r(" = $ret\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100400if ($ret != \ThriftTest\Numberz::EIGHT) {
401 echo "**FAILED**\n";
402 $exitcode |= ERR_STRUCTS;
403}
Mark Slee6e536442006-06-30 18:28:50 +0000404
405/**
406 * TYPEDEF TEST
407 */
408print_r("testTypedef(309858235082523)");
409$uid = $testClient->testTypedef(309858235082523);
410print_r(" = $uid\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100411if ($uid !== 309858235082523) {
412 echo "**FAILED**\n";
413 $exitcode |= ERR_STRUCTS;
414}
Mark Slee6e536442006-06-30 18:28:50 +0000415
416/**
417 * NESTED MAP TEST
418 */
419print_r("testMapMap(1)");
420$mm = $testClient->testMapMap(1);
421print_r(" = {");
422foreach ($mm as $key => $val) {
423 print_r("$key => {");
424 foreach ($val as $k2 => $v2) {
425 print_r("$k2 => $v2, ");
426 }
427 print_r("}, ");
428}
429print_r("}\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100430$expected_mm = [
431 -4 => [-4 => -4, -3 => -3, -2 => -2, -1 => -1],
432 4 => [4 => 4, 3 => 3, 2 => 2, 1 => 1],
433];
434if ($mm != $expected_mm) {
435 echo "**FAILED**\n";
436 $exitcode |= ERR_CONTAINERS;
437}
Mark Slee6e536442006-06-30 18:28:50 +0000438
439/**
440 * INSANITY TEST
441 */
Roger Meier21c0a852012-09-05 19:47:14 +0000442$insane = new \ThriftTest\Insanity();
Roger Meier87afaac2013-01-06 20:10:42 +0100443$insane->userMap[\ThriftTest\Numberz::FIVE] = 5000;
Roger Meier21c0a852012-09-05 19:47:14 +0000444$truck = new \ThriftTest\Xtruct();
Mark Slee6e536442006-06-30 18:28:50 +0000445$truck->string_thing = "Truck";
446$truck->byte_thing = 8;
447$truck->i32_thing = 8;
448$truck->i64_thing = 8;
449$insane->xtructs []= $truck;
450print_r("testInsanity()");
451$whoa = $testClient->testInsanity($insane);
452print_r(" = {");
453foreach ($whoa as $key => $val) {
454 print_r("$key => {");
455 foreach ($val as $k2 => $v2) {
456 print_r("$k2 => {");
457 $userMap = $v2->userMap;
458 print_r("{");
Bryan Duxburya971fb02011-03-04 00:49:40 +0000459 if (is_array($userMap)) {
Mark Sleed3d733a2006-09-01 22:19:06 +0000460 foreach ($userMap as $k3 => $v3) {
461 print_r("$k3 => $v3, ");
462 }
Mark Slee6e536442006-06-30 18:28:50 +0000463 }
464 print_r("}, ");
Mark Slee5b743072007-11-13 04:00:29 +0000465
Mark Slee6e536442006-06-30 18:28:50 +0000466 $xtructs = $v2->xtructs;
467 print_r("{");
Mark Sleed3d733a2006-09-01 22:19:06 +0000468 if (is_array($xtructs)) {
469 foreach ($xtructs as $x) {
470 print_r("{\"".$x->string_thing."\", ".
471 $x->byte_thing.", ".$x->i32_thing.", ".$x->i64_thing."}, ");
472 }
Mark Slee6e536442006-06-30 18:28:50 +0000473 }
474 print_r("}");
Mark Slee5b743072007-11-13 04:00:29 +0000475
Mark Slee6e536442006-06-30 18:28:50 +0000476 print_r("}, ");
477 }
478 print_r("}, ");
479}
480print_r("}\n");
481
Mark Sleed3d733a2006-09-01 22:19:06 +0000482/**
483 * EXCEPTION TEST
484 */
485print_r("testException('Xception')");
486try {
487 $testClient->testException('Xception');
488 print_r(" void\nFAILURE\n");
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100489 $exitcode |= ERR_EXCEPTIONS;
Roger Meier87afaac2013-01-06 20:10:42 +0100490} catch (\ThriftTest\Xception $x) {
Mark Sleed3d733a2006-09-01 22:19:06 +0000491 print_r(' caught xception '.$x->errorCode.': '.$x->message."\n");
492}
493
Roy Sindre Norangsholec64f232017-07-26 20:49:38 +0200494// Regression test for THRIFT-4263
495print_r("testBinarySerializer_Deserialize('foo')");
496try {
497 \Thrift\Serializer\TBinarySerializer::deserialize(base64_decode('foo'), \ThriftTest\Xtruct2::class);
498 echo "**FAILED**\n";
499 $exitcode |= ERR_STRUCTS;
500} catch (\Thrift\Exception\TTransportException $happy_exception) {
501 // We expected this due to binary data of base64_decode('foo') is less then 4
502 // bytes and it tries to find thrift version number in the transport by
503 // reading i32() at the beginning. Casting to string validates that
504 // exception is still accessible in memory and not corrupted. Without patch,
505 // PHP will error log that the exception doesn't have any tostring method,
506 // which is a lie due to corrupted memory.
507 for($i=99; $i > 0; $i--) {
508 (string)$happy_exception;
509 }
510 print_r(" SUCCESS\n");
511}
512
Mark Slee6e536442006-06-30 18:28:50 +0000513/**
514 * Normal tests done.
515 */
516
517$stop = microtime(true);
518$elp = round(1000*($stop - $start), 0);
519print_r("Total time: $elp ms\n");
520
521/**
522 * Extraneous "I don't trust PHP to pack/unpack integer" tests
523 */
524
Håkon Hitlande66b8fc2016-12-05 18:42:41 +0100525if ($protocol instanceof TBinaryProtocolAccelerated) {
526 // Regression check: check that method name is not double-freed
527 // Method name should not be an interned string.
528 $method_name = "Void";
529 $method_name = "test$method_name";
530
531 $seqid = 0;
532 $args = new \ThriftTest\ThriftTest_testVoid_args();
533 thrift_protocol_write_binary($protocol, $method_name, \Thrift\Type\TMessageType::CALL, $args, $seqid, $protocol->isStrictWrite());
534 $testClient->recv_testVoid();
535
536}
537
Mark Slee6e536442006-06-30 18:28:50 +0000538// Max I32
539$num = pow(2, 30) + (pow(2, 30) - 1);
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100540roundtrip($testClient, 'testI32', $num);
Mark Slee6e536442006-06-30 18:28:50 +0000541
542// Min I32
543$num = 0 - pow(2, 31);
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100544roundtrip($testClient, 'testI32', $num);
Mark Slee6e536442006-06-30 18:28:50 +0000545
546// Max I64
547$num = pow(2, 62) + (pow(2, 62) - 1);
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100548roundtrip($testClient, 'testI64', $num);
Mark Slee6e536442006-06-30 18:28:50 +0000549
550// Min I64
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900551$num = 0 - pow(2, 62) - pow(2, 62);
Håkon Hitlandf39d4c82016-11-17 16:18:03 +0100552roundtrip($testClient, 'testI64', $num);
Mark Slee6e536442006-06-30 18:28:50 +0000553
Mark Sleed3d733a2006-09-01 22:19:06 +0000554$transport->close();
Nobuaki Sukegawae4ba1642016-07-22 18:09:32 +0900555exit($exitcode);