summaryrefslogtreecommitdiff
path: root/test/php
diff options
context:
space:
mode:
authorRoger Meier <roger@apache.org>2012-09-05 19:47:14 +0000
committerRoger Meier <roger@apache.org>2012-09-05 19:47:14 +0000
commit21c0a85079e3e1b5ee475bd6654512079fe5df68 (patch)
tree4cff5730f356949cb848fef0b110a92a56541ff6 /test/php
parentf88f9c231ebcd8f19bb040f78bc03e6b33a2982c (diff)
downloadthrift-21c0a85079e3e1b5ee475bd6654512079fe5df68.tar.gz
THRIFT-1615 PHP Namespace (was Thrift for Symfony 2)
Patch: Xavier HAUSHERR git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1381323 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/php')
-rwxr-xr-xtest/php/TestClient.php66
1 files changed, 31 insertions, 35 deletions
diff --git a/test/php/TestClient.php b/test/php/TestClient.php
index 009137b37..4df498c8d 100755
--- a/test/php/TestClient.php
+++ b/test/php/TestClient.php
@@ -1,4 +1,23 @@
<?php
+
+namespace test\php;
+
+require_once __DIR__.'/../../lib/php/lib/Thrift/ClassLoader/ThriftClassLoader.php';
+
+use Thrift\ClassLoader\ThriftClassLoader;
+
+if (!isset($GEN_DIR)) {
+ $GEN_DIR = 'gen-php';
+}
+if (!isset($MODE)) {
+ $MODE = 'normal';
+}
+
+$loader = new ThriftClassLoader();
+$loader->registerNamespace('Thrift', __DIR__ . '/../../lib/php/lib');
+$loader->registerDefinition('ThriftTest', $GEN_DIR);
+$loader->register();
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,40 +37,17 @@
* under the License.
*/
-if (!isset($GEN_DIR)) {
- $GEN_DIR = 'gen-php';
-}
-if (!isset($MODE)) {
- $MODE = 'normal';
-}
-
-/** Set the Thrift root */
-$GLOBALS['THRIFT_ROOT'] = '../../lib/php/src';
-
/** Include the Thrift base */
-require_once $GLOBALS['THRIFT_ROOT'].'/Thrift.php';
-
/** Include the binary protocol */
-require_once $GLOBALS['THRIFT_ROOT'].'/protocol/TBinaryProtocol.php';
+use Thrift\Protocol\TBinaryProtocol;
/** Include the socket layer */
-require_once $GLOBALS['THRIFT_ROOT'].'/transport/TSocketPool.php';
+use Thrift\Transport\TSocket;
+use Thrift\Transport\TSocketPool;
/** Include the socket layer */
-require_once $GLOBALS['THRIFT_ROOT'].'/transport/TFramedTransport.php';
-require_once $GLOBALS['THRIFT_ROOT'].'/transport/TBufferedTransport.php';
-
-echo '==============================='."\n";
-echo ' SAFE TO IGNORE THESE IN TEST'."\n";
-echo '==============================='."\n";
-
-/** Include the generated code */
-require_once $GEN_DIR.'/ThriftTest/ThriftTest.php';
-require_once $GEN_DIR.'/ThriftTest/ThriftTest_types.php';
-
-echo '==============================='."\n";
-echo ' END OF SAFE ERRORS SECTION'."\n";
-echo '==============================='."\n\n";
+use Thrift\Transport\TFramedTransport;
+use Thrift\Transport\TBufferedTransport;
$host = 'localhost';
$port = 9090;
@@ -72,17 +68,17 @@ $socket->setDebug(TRUE);
if ($MODE == 'inline') {
$transport = $socket;
- $testClient = new ThriftTest_ThriftTestClient($transport);
+ $testClient = new \ThriftTest\ThriftTestClient($transport);
} else if ($MODE == 'framed') {
$framedSocket = new TFramedTransport($socket);
$transport = $framedSocket;
$protocol = new TBinaryProtocol($transport);
- $testClient = new ThriftTest_ThriftTestClient($protocol);
+ $testClient = new \ThriftTest\ThriftTestClient($protocol);
} else {
$bufferedSocket = new TBufferedTransport($socket, 1024, 1024);
$transport = $bufferedSocket;
$protocol = new TBinaryProtocol($transport);
- $testClient = new ThriftTest_ThriftTestClient($protocol);
+ $testClient = new \ThriftTest\ThriftTestClient($protocol);
}
$transport->open();
@@ -135,7 +131,7 @@ print_r(" = $dub\n");
* STRUCT TEST
*/
print_r("testStruct({\"Zero\", 1, -3, -5})");
-$out = new ThriftTest_Xtruct();
+$out = new \ThriftTest\Xtruct();
$out->string_thing = "Zero";
$out->byte_thing = 1;
$out->i32_thing = -3;
@@ -150,7 +146,7 @@ print_r(" = {\"".$in->string_thing."\", ".
* NESTED STRUCT TEST
*/
print_r("testNest({1, {\"Zero\", 1, -3, -5}), 5}");
-$out2 = new ThriftTest_Xtruct2();
+$out2 = new \ThriftTest\Xtruct2();
$out2->byte_thing = 1;
$out2->struct_thing = $out;
$out2->i32_thing = 5;
@@ -305,9 +301,9 @@ print_r("}\n");
/**
* INSANITY TEST
*/
-$insane = new ThriftTest_Insanity();
+$insane = new \ThriftTest\Insanity();
$insane->userMap[ThriftTest_Numberz::FIVE] = 5000;
-$truck = new ThriftTest_Xtruct();
+$truck = new \ThriftTest\Xtruct();
$truck->string_thing = "Truck";
$truck->byte_thing = 8;
$truck->i32_thing = 8;