summaryrefslogtreecommitdiff
path: root/test/php
diff options
context:
space:
mode:
authorAndreas Scheja <a.scheja@gmail.com>2016-05-15 21:49:04 +0200
committerNobuaki Sukegawa <nsuke@apache.org>2016-09-03 15:58:37 +0900
commitd1ceba449d3c6bb431386abc11495f21f9824238 (patch)
tree269cce3c7910b3332afd2b3c977ddb707f10d17c /test/php
parent7b0cb9a63aff78c03e6ff2cd1d266b408a22df7f (diff)
downloadthrift-d1ceba449d3c6bb431386abc11495f21f9824238.tar.gz
THRIFT-3046: Allow PSR4 class loading for generated classes (PHP)
Allow test to be used with psr4 autoloading This closes #1010
Diffstat (limited to 'test/php')
-rwxr-xr-xtest/php/Makefile.am4
-rwxr-xr-xtest/php/TestClient.php6
-rw-r--r--test/php/TestPsr4.php23
3 files changed, 31 insertions, 2 deletions
diff --git a/test/php/Makefile.am b/test/php/Makefile.am
index 11974da0b..7c4347ff1 100755
--- a/test/php/Makefile.am
+++ b/test/php/Makefile.am
@@ -22,13 +22,15 @@ THRIFT = $(top_builddir)/compiler/cpp/thrift
stubs: ../ThriftTest.thrift
$(THRIFT) --gen php ../ThriftTest.thrift
$(THRIFT) --gen php:inlined ../ThriftTest.thrift
+ $(MKDIR_P) gen-php-psr4
+ $(THRIFT) -out gen-php-psr4 --gen php:psr4 ../ThriftTest.thrift
precross: stubs
check: stubs
clean-local:
- $(RM) -r gen-php gen-phpi
+ $(RM) -r gen-php gen-phpi gen-php-psr4
client: stubs
php TestClient.php
diff --git a/test/php/TestClient.php b/test/php/TestClient.php
index 946334d9d..2443ee058 100755
--- a/test/php/TestClient.php
+++ b/test/php/TestClient.php
@@ -15,7 +15,11 @@ if (!isset($MODE)) {
$loader = new ThriftClassLoader();
$loader->registerNamespace('Thrift', __DIR__ . '/../../lib/php/lib');
-$loader->registerDefinition('ThriftTest', $GEN_DIR);
+if ($GEN_DIR === 'gen-php-psr4') {
+ $loader->registerNamespace('ThriftTest', $GEN_DIR);
+} else {
+ $loader->registerDefinition('ThriftTest', $GEN_DIR);
+}
$loader->register();
/*
diff --git a/test/php/TestPsr4.php b/test/php/TestPsr4.php
new file mode 100644
index 000000000..d30bf1c49
--- /dev/null
+++ b/test/php/TestPsr4.php
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+<?php
+$GEN_DIR = 'gen-php-psr4';
+include_once('TestClient.php');
+?>