Unverified Commit d7c44095 authored by Paul Yang's avatar Paul Yang Committed by GitHub

Php 7.3 fix (#5434)

* Inherit from message instead of implement

When regestering class (implmenets other class) during MINIT, zend_class_implements
would call zend_class_entry->interface_gets_implemented(). In PHP-7.3 interface_gets_implemented shares the same location with create_object.
However, during MINIT, the global object storeage hasn't been initialized. And thus, caused segment fault in php 7.3.

* Use zend_string_init where interned string may be the value.
zend_string_dup will keep using the existing interned string.
In php 7.3, interned string cannot be destroyed from user's code.

* Uncommment debug code

* Use latest phpunit for each php versions

* Revert change in Dockerfile

* Update php test to use the new docker image

* Update composer

* Change docker organization

* Update phpunit

* Debug phpunit

* Store phpunit into bin dir in docker image

* Install valgrind to docker

* Fix compatibility test

* Remove generated_service_test from compatibility c extension test

* Update 32bit php test to the new docker image

* Install bison

* Fix build.sh

* Fix DOCKERIMAGE_PREFIX

* Fix basename

* Add comment to build_and_run_docker2.sh

* Remove commented code

* Fix comments
parent d529720e
...@@ -145,7 +145,9 @@ php/ext/google/protobuf/Makefile.objects ...@@ -145,7 +145,9 @@ php/ext/google/protobuf/Makefile.objects
php/ext/google/protobuf/acinclude.m4 php/ext/google/protobuf/acinclude.m4
php/ext/google/protobuf/build/ php/ext/google/protobuf/build/
php/ext/google/protobuf/config.h php/ext/google/protobuf/config.h
php/ext/google/protobuf/config.h.in~
php/ext/google/protobuf/config.nice php/ext/google/protobuf/config.nice
php/ext/google/protobuf/configure.ac
php/ext/google/protobuf/configure.in php/ext/google/protobuf/configure.in
php/ext/google/protobuf/mkinstalldirs php/ext/google/protobuf/mkinstalldirs
php/ext/google/protobuf/run-tests.php php/ext/google/protobuf/run-tests.php
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
# Change to repo root # Change to repo root
cd $(dirname $0)/../../.. cd $(dirname $0)/../../..
export DOCKERFILE_DIR=kokoro/linux/32-bit export DOCKERHUB_ORGANIZATION=protobuftesting
export DOCKERFILE_DIR=kokoro/linux/dockerfile/test/php_32bit
export DOCKER_RUN_SCRIPT=kokoro/linux/pull_request_in_docker.sh export DOCKER_RUN_SCRIPT=kokoro/linux/pull_request_in_docker.sh
export OUTPUT_DIR=testoutput export OUTPUT_DIR=testoutput
export TEST_SET="php_all_32" export TEST_SET="php_all_32"
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
# Builds docker image and runs a command under it. # Builds docker image and runs a command under it.
# This is a generic script that is configured with the following variables: # This is a generic script that is configured with the following variables:
# #
# DOCKERHUB_ORGANIZATION - The organization on docker hub storing the
# Dockerfile.
# DOCKERFILE_DIR - Directory in which Dockerfile file is located. # DOCKERFILE_DIR - Directory in which Dockerfile file is located.
# DOCKER_RUN_SCRIPT - Script to run under docker (relative to protobuf repo root) # DOCKER_RUN_SCRIPT - Script to run under docker (relative to protobuf repo root)
# OUTPUT_DIR - Directory that will be copied from inside docker after finishing. # OUTPUT_DIR - Directory that will be copied from inside docker after finishing.
...@@ -15,8 +17,16 @@ git_root=$(pwd) ...@@ -15,8 +17,16 @@ git_root=$(pwd)
cd - cd -
# Use image name based on Dockerfile sha1 # Use image name based on Dockerfile sha1
DOCKERHUB_ORGANIZATION=grpctesting/protobuf if [ -z "$DOCKERHUB_ORGANIZATION" ]
DOCKER_IMAGE_NAME=${DOCKERHUB_ORGANIZATION}_$(sha1sum $DOCKERFILE_DIR/Dockerfile | cut -f1 -d\ ) then
DOCKERHUB_ORGANIZATION=grpctesting/protobuf
DOCKER_IMAGE_NAME=${DOCKERHUB_ORGANIZATION}_$(sha1sum $DOCKERFILE_DIR/Dockerfile | cut -f1 -d\ )
else
# TODO(teboring): Remove this when all tests have been migrated to separate
# docker images.
DOCKERFILE_PREFIX=$(basename $DOCKERFILE_DIR)
DOCKER_IMAGE_NAME=${DOCKERHUB_ORGANIZATION}/${DOCKERFILE_PREFIX}_$(sha1sum $DOCKERFILE_DIR/Dockerfile | cut -f1 -d\ )
fi
# Pull dockerimage from Dockerhub # Pull dockerimage from Dockerhub
docker pull $DOCKER_IMAGE_NAME docker pull $DOCKER_IMAGE_NAME
......
...@@ -79,8 +79,8 @@ RUN cd php-src \ ...@@ -79,8 +79,8 @@ RUN cd php-src \
RUN wget -O phpunit https://phar.phpunit.de/phpunit-4.phar \ RUN wget -O phpunit https://phar.phpunit.de/phpunit-4.phar \
&& chmod +x phpunit \ && chmod +x phpunit \
&& cp phpunit /usr/local/php-5.5 \ && cp phpunit /usr/local/php-5.5/bin \
&& mv phpunit /usr/local/php-5.5-zts && mv phpunit /usr/local/php-5.5-zts/bin
# php 5.6 # php 5.6
RUN cd php-src \ RUN cd php-src \
...@@ -109,8 +109,8 @@ RUN cd php-src \ ...@@ -109,8 +109,8 @@ RUN cd php-src \
RUN wget -O phpunit https://phar.phpunit.de/phpunit-5.phar \ RUN wget -O phpunit https://phar.phpunit.de/phpunit-5.phar \
&& chmod +x phpunit \ && chmod +x phpunit \
&& cp phpunit /usr/local/php-5.6 \ && cp phpunit /usr/local/php-5.6/bin \
&& mv phpunit /usr/local/php-5.6-zts && mv phpunit /usr/local/php-5.6-zts/bin
# php 7.0 # php 7.0
RUN cd php-src \ RUN cd php-src \
...@@ -139,8 +139,8 @@ RUN cd php-src \ ...@@ -139,8 +139,8 @@ RUN cd php-src \
RUN wget -O phpunit https://phar.phpunit.de/phpunit-6.phar \ RUN wget -O phpunit https://phar.phpunit.de/phpunit-6.phar \
&& chmod +x phpunit \ && chmod +x phpunit \
&& cp phpunit /usr/local/php-7.0 \ && cp phpunit /usr/local/php-7.0/bin \
&& mv phpunit /usr/local/php-7.0-zts && mv phpunit /usr/local/php-7.0-zts/bin
# php 7.1 # php 7.1
RUN cd php-src \ RUN cd php-src \
...@@ -169,8 +169,8 @@ RUN cd php-src \ ...@@ -169,8 +169,8 @@ RUN cd php-src \
RUN wget -O phpunit https://phar.phpunit.de/phpunit-7.phar \ RUN wget -O phpunit https://phar.phpunit.de/phpunit-7.phar \
&& chmod +x phpunit \ && chmod +x phpunit \
&& cp phpunit /usr/local/php-7.1 \ && cp phpunit /usr/local/php-7.1/bin \
&& mv phpunit /usr/local/php-7.1-zts && mv phpunit /usr/local/php-7.1-zts/bin
# php 7.2 # php 7.2
RUN cd php-src \ RUN cd php-src \
...@@ -199,8 +199,8 @@ RUN cd php-src \ ...@@ -199,8 +199,8 @@ RUN cd php-src \
RUN wget -O phpunit https://phar.phpunit.de/phpunit-7.phar \ RUN wget -O phpunit https://phar.phpunit.de/phpunit-7.phar \
&& chmod +x phpunit \ && chmod +x phpunit \
&& cp phpunit /usr/local/php-7.2 \ && cp phpunit /usr/local/php-7.2/bin \
&& mv phpunit /usr/local/php-7.2-zts && mv phpunit /usr/local/php-7.2-zts/bin
# php 7.3 # php 7.3
RUN cd php-src \ RUN cd php-src \
...@@ -229,5 +229,10 @@ RUN cd php-src \ ...@@ -229,5 +229,10 @@ RUN cd php-src \
RUN wget -O phpunit https://phar.phpunit.de/phpunit-7.phar \ RUN wget -O phpunit https://phar.phpunit.de/phpunit-7.phar \
&& chmod +x phpunit \ && chmod +x phpunit \
&& cp phpunit /usr/local/php-7.3 \ && cp phpunit /usr/local/php-7.3/bin \
&& mv phpunit /usr/local/php-7.3-zts && mv phpunit /usr/local/php-7.3-zts/bin
# Install php dependencies
RUN apt-get clean && apt-get update && apt-get install -y --force-yes \
valgrind \
&& apt-get clean
FROM 32bit/debian:jessie
# Install dependencies. We start with the basic ones require to build protoc
# and the C++ build
RUN apt-get update && apt-get install -y \
autoconf \
autotools-dev \
build-essential \
bzip2 \
ccache \
curl \
gcc \
git \
libc6 \
libc6-dbg \
libc6-dev \
libgtest-dev \
libtool \
make \
parallel \
time \
wget \
&& apt-get clean
# Install php dependencies
RUN apt-get clean && apt-get update && apt-get install -y --force-yes \
bison \
php5 \
libcurl4-openssl-dev \
libssl-dev \
libxml2-dev \
unzip \
zlib1g-dev \
pkg-config \
&& apt-get clean
# Install other dependencies
RUN wget http://ftp.gnu.org/gnu/bison/bison-2.6.4.tar.gz -O /var/local/bison-2.6.4.tar.gz
RUN cd /var/local \
&& tar -zxvf bison-2.6.4.tar.gz \
&& cd /var/local/bison-2.6.4 \
&& ./configure \
&& make \
&& make install
# Install composer
RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
# Download php source code
RUN git clone https://github.com/php/php-src
# php 5.5
RUN cd php-src \
&& git checkout PHP-5.5.38 \
&& ./buildconf --force
RUN cd php-src \
&& ./configure \
--enable-bcmath \
--with-openssl \
--with-zlib \
--prefix=/usr/local/php-5.5 \
&& make \
&& make install \
&& make clean
RUN cd php-src \
&& ./configure \
--enable-maintainer-zts \
--with-openssl \
--with-zlib \
--prefix=/usr/local/php-5.5-zts \
&& make \
&& make install \
&& make clean
RUN wget -O phpunit https://phar.phpunit.de/phpunit-4.phar \
&& chmod +x phpunit \
&& cp phpunit /usr/local/php-5.5/bin \
&& mv phpunit /usr/local/php-5.5-zts/bin
# php 5.6
RUN cd php-src \
&& git checkout PHP-5.6.39 \
&& ./buildconf --force
RUN cd php-src \
&& ./configure \
--enable-bcmath \
--with-openssl \
--with-zlib \
--prefix=/usr/local/php-5.6 \
&& make \
&& make install \
&& make clean
RUN cd php-src \
&& ./configure \
--enable-maintainer-zts \
--with-openssl \
--with-zlib \
--prefix=/usr/local/php-5.6-zts \
&& make \
&& make install \
&& make clean
RUN wget -O phpunit https://phar.phpunit.de/phpunit-5.phar \
&& chmod +x phpunit \
&& cp phpunit /usr/local/php-5.6/bin \
&& mv phpunit /usr/local/php-5.6-zts/bin
# php 7.0
RUN cd php-src \
&& git checkout PHP-7.0.33 \
&& ./buildconf --force
RUN cd php-src \
&& ./configure \
--enable-bcmath \
--with-openssl \
--with-zlib \
--prefix=/usr/local/php-7.0 \
&& make \
&& make install \
&& make clean
RUN cd php-src \
&& ./configure \
--enable-maintainer-zts \
--with-openssl \
--with-zlib \
--prefix=/usr/local/php-7.0-zts \
&& make \
&& make install \
&& make clean
RUN wget -O phpunit https://phar.phpunit.de/phpunit-6.phar \
&& chmod +x phpunit \
&& cp phpunit /usr/local/php-7.0/bin \
&& mv phpunit /usr/local/php-7.0-zts/bin
# php 7.1
RUN cd php-src \
&& git checkout PHP-7.1.25 \
&& ./buildconf --force
RUN cd php-src \
&& ./configure \
--enable-bcmath \
--with-openssl \
--with-zlib \
--prefix=/usr/local/php-7.1 \
&& make \
&& make install \
&& make clean
RUN cd php-src \
&& ./configure \
--enable-maintainer-zts \
--with-openssl \
--with-zlib \
--prefix=/usr/local/php-7.1-zts \
&& make \
&& make install \
&& make clean
RUN wget -O phpunit https://phar.phpunit.de/phpunit-7.phar \
&& chmod +x phpunit \
&& cp phpunit /usr/local/php-7.1/bin \
&& mv phpunit /usr/local/php-7.1-zts/bin
# php 7.2
RUN cd php-src \
&& git checkout PHP-7.2.13 \
&& ./buildconf --force
RUN cd php-src \
&& ./configure \
--enable-bcmath \
--with-openssl \
--with-zlib \
--prefix=/usr/local/php-7.2 \
&& make \
&& make install \
&& make clean
RUN cd php-src \
&& ./configure \
--enable-maintainer-zts \
--with-openssl \
--with-zlib \
--prefix=/usr/local/php-7.2-zts \
&& make \
&& make install \
&& make clean
RUN wget -O phpunit https://phar.phpunit.de/phpunit-7.phar \
&& chmod +x phpunit \
&& cp phpunit /usr/local/php-7.2/bin \
&& mv phpunit /usr/local/php-7.2-zts/bin
# php 7.3
RUN cd php-src \
&& git checkout PHP-7.3.0 \
&& ./buildconf --force
RUN cd php-src \
&& ./configure \
--enable-bcmath \
--with-openssl \
--with-zlib \
--prefix=/usr/local/php-7.3 \
&& make \
&& make install \
&& make clean
RUN cd php-src \
&& ./configure \
--enable-maintainer-zts \
--with-openssl \
--with-zlib \
--prefix=/usr/local/php-7.3-zts \
&& make \
&& make install \
&& make clean
RUN wget -O phpunit https://phar.phpunit.de/phpunit-7.phar \
&& chmod +x phpunit \
&& cp phpunit /usr/local/php-7.3/bin \
&& mv phpunit /usr/local/php-7.3-zts/bin
# Install php dependencies
RUN apt-get clean && apt-get update && apt-get install -y --force-yes \
valgrind \
&& apt-get clean
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
# Change to repo root # Change to repo root
cd $(dirname $0)/../../.. cd $(dirname $0)/../../..
export DOCKERFILE_DIR=kokoro/linux/64-bit export DOCKERHUB_ORGANIZATION=protobuftesting
export DOCKERFILE_DIR=kokoro/linux/dockerfile/test/php
export DOCKER_RUN_SCRIPT=kokoro/linux/pull_request_in_docker.sh export DOCKER_RUN_SCRIPT=kokoro/linux/pull_request_in_docker.sh
export OUTPUT_DIR=testoutput export OUTPUT_DIR=testoutput
export TEST_SET="php_all" export TEST_SET="php_all"
......
This diff is collapsed.
...@@ -137,7 +137,8 @@ ...@@ -137,7 +137,8 @@
const char* class_name = CLASSNAME; \ const char* class_name = CLASSNAME; \
INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \ INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \
LOWWERNAME##_methods); \ LOWWERNAME##_methods); \
LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC); \ LOWWERNAME##_type = zend_register_internal_class_ex( \
&class_type, message_type, NULL TSRMLS_CC); \
LOWWERNAME##_type->create_object = message_create; \ LOWWERNAME##_type->create_object = message_create; \
zend_do_inheritance(LOWWERNAME##_type, message_type TSRMLS_CC); zend_do_inheritance(LOWWERNAME##_type, message_type TSRMLS_CC);
#define PHP_PROTO_INIT_SUBMSGCLASS_END \ #define PHP_PROTO_INIT_SUBMSGCLASS_END \
...@@ -404,7 +405,8 @@ static inline int php_proto_zend_hash_get_current_data_ex(HashTable* ht, ...@@ -404,7 +405,8 @@ static inline int php_proto_zend_hash_get_current_data_ex(HashTable* ht,
const char* class_name = CLASSNAME; \ const char* class_name = CLASSNAME; \
INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \ INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \
LOWWERNAME##_methods); \ LOWWERNAME##_methods); \
LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC); \ LOWWERNAME##_type = zend_register_internal_class_ex( \
&class_type, message_type TSRMLS_CC); \
zend_do_inheritance(LOWWERNAME##_type, message_type TSRMLS_CC); zend_do_inheritance(LOWWERNAME##_type, message_type TSRMLS_CC);
#define PHP_PROTO_INIT_SUBMSGCLASS_END \ #define PHP_PROTO_INIT_SUBMSGCLASS_END \
} }
......
...@@ -180,7 +180,8 @@ bool native_slot_set_by_array(upb_fieldtype_t type, ...@@ -180,7 +180,8 @@ bool native_slot_set_by_array(upb_fieldtype_t type,
PHP_PROTO_ZVAL_STRINGL(DEREF(memory, zval*), Z_STRVAL_P(value), PHP_PROTO_ZVAL_STRINGL(DEREF(memory, zval*), Z_STRVAL_P(value),
Z_STRLEN_P(value), 1); Z_STRLEN_P(value), 1);
#else #else
*(zend_string**)memory = zend_string_dup(Z_STR_P(value), 0); *(zend_string**)memory =
zend_string_init(Z_STRVAL_P(value), Z_STRLEN_P(value), 0);
#endif #endif
break; break;
} }
...@@ -231,7 +232,8 @@ bool native_slot_set_by_map(upb_fieldtype_t type, const zend_class_entry* klass, ...@@ -231,7 +232,8 @@ bool native_slot_set_by_map(upb_fieldtype_t type, const zend_class_entry* klass,
PHP_PROTO_ZVAL_STRINGL(DEREF(memory, zval*), Z_STRVAL_P(value), PHP_PROTO_ZVAL_STRINGL(DEREF(memory, zval*), Z_STRVAL_P(value),
Z_STRLEN_P(value), 1); Z_STRLEN_P(value), 1);
#else #else
*(zend_string**)memory = zend_string_dup(Z_STR_P(value), 0); *(zend_string**)memory =
zend_string_init(Z_STRVAL_P(value), Z_STRLEN_P(value), 0);
#endif #endif
break; break;
} }
......
...@@ -7,7 +7,7 @@ use Google\Protobuf\Internal\GPBType; ...@@ -7,7 +7,7 @@ use Google\Protobuf\Internal\GPBType;
use Foo\TestMessage; use Foo\TestMessage;
use Foo\TestMessage\Sub; use Foo\TestMessage\Sub;
class RepeatedFieldTest extends PHPUnit_Framework_TestCase class RepeatedFieldTest extends \PHPUnit\Framework\TestCase
{ {
######################################################### #########################################################
......
...@@ -123,8 +123,12 @@ tests=( array_test.php encode_decode_test.php generated_class_test.php map_field ...@@ -123,8 +123,12 @@ tests=( array_test.php encode_decode_test.php generated_class_test.php map_field
sed -i.bak '/php_implementation_test.php/d' phpunit.xml sed -i.bak '/php_implementation_test.php/d' phpunit.xml
sed -i.bak '/generated_phpdoc_test.php/d' phpunit.xml sed -i.bak '/generated_phpdoc_test.php/d' phpunit.xml
sed -i.bak 's/generated_phpdoc_test.php//g' tests/test.sh sed -i.bak 's/generated_phpdoc_test.php//g' tests/test.sh
sed -i.bak 's/generated_service_test.php//g' tests/test.sh
sed -i.bak '/memory_leak_test.php/d' tests/test.sh sed -i.bak '/memory_leak_test.php/d' tests/test.sh
sed -i.bak '/^ public function testTimestamp()$/,/^ }$/d' tests/well_known_test.php sed -i.bak '/^ public function testTimestamp()$/,/^ }$/d' tests/well_known_test.php
sed -i.bak 's/PHPUnit_Framework_TestCase/\\PHPUnit\\Framework\\TestCase/g' tests/array_test.php
sed -i.bak 's/PHPUnit_Framework_TestCase/\\PHPUnit\\Framework\\TestCase/g' tests/map_field_test.php
sed -i.bak 's/PHPUnit_Framework_TestCase/\\PHPUnit\\Framework\\TestCase/g' tests/test_base.php
for t in "${tests[@]}" for t in "${tests[@]}"
do do
remove_error_test tests/$t remove_error_test tests/$t
......
...@@ -31,6 +31,7 @@ class EncodeDecodeTest extends TestBase ...@@ -31,6 +31,7 @@ class EncodeDecodeTest extends TestBase
{ {
$m = new TestMessage(); $m = new TestMessage();
$m->mergeFromJsonString("{\"optionalInt32\":1}"); $m->mergeFromJsonString("{\"optionalInt32\":1}");
$this->assertEquals(1, $m->getOptionalInt32());
} }
public function testDecodeTopLevelBoolValue() public function testDecodeTopLevelBoolValue()
...@@ -276,6 +277,7 @@ class EncodeDecodeTest extends TestBase ...@@ -276,6 +277,7 @@ class EncodeDecodeTest extends TestBase
$to = new TestPackedMessage(); $to = new TestPackedMessage();
$to->mergeFromString(TestUtil::getGoldenTestPackedMessage()); $to->mergeFromString(TestUtil::getGoldenTestPackedMessage());
TestUtil::assertTestPackedMessage($to); TestUtil::assertTestPackedMessage($to);
$this->assertTrue(true);
} }
public function testPackedDecodeUnpacked() public function testPackedDecodeUnpacked()
...@@ -283,6 +285,7 @@ class EncodeDecodeTest extends TestBase ...@@ -283,6 +285,7 @@ class EncodeDecodeTest extends TestBase
$to = new TestPackedMessage(); $to = new TestPackedMessage();
$to->mergeFromString(TestUtil::getGoldenTestUnpackedMessage()); $to->mergeFromString(TestUtil::getGoldenTestUnpackedMessage());
TestUtil::assertTestPackedMessage($to); TestUtil::assertTestPackedMessage($to);
$this->assertTrue(true);
} }
public function testUnpackedEncode() public function testUnpackedEncode()
...@@ -298,6 +301,7 @@ class EncodeDecodeTest extends TestBase ...@@ -298,6 +301,7 @@ class EncodeDecodeTest extends TestBase
$to = new TestUnpackedMessage(); $to = new TestUnpackedMessage();
$to->mergeFromString(TestUtil::getGoldenTestPackedMessage()); $to->mergeFromString(TestUtil::getGoldenTestPackedMessage());
TestUtil::assertTestPackedMessage($to); TestUtil::assertTestPackedMessage($to);
$this->assertTrue(true);
} }
public function testUnpackedDecodeUnpacked() public function testUnpackedDecodeUnpacked()
...@@ -305,6 +309,7 @@ class EncodeDecodeTest extends TestBase ...@@ -305,6 +309,7 @@ class EncodeDecodeTest extends TestBase
$to = new TestUnpackedMessage(); $to = new TestUnpackedMessage();
$to->mergeFromString(TestUtil::getGoldenTestUnpackedMessage()); $to->mergeFromString(TestUtil::getGoldenTestUnpackedMessage());
TestUtil::assertTestPackedMessage($to); TestUtil::assertTestPackedMessage($to);
$this->assertTrue(true);
} }
public function testDecodeInt64() public function testDecodeInt64()
...@@ -361,6 +366,7 @@ class EncodeDecodeTest extends TestBase ...@@ -361,6 +366,7 @@ class EncodeDecodeTest extends TestBase
$data = hex2bin('c80501'); $data = hex2bin('c80501');
$m = new TestMessage(); $m = new TestMessage();
$m->mergeFromString($data); $m->mergeFromString($data);
$this->assertTrue(true);
} }
public function testEncodeNegativeInt32() public function testEncodeNegativeInt32()
......
...@@ -260,12 +260,14 @@ class GeneratedClassTest extends TestBase ...@@ -260,12 +260,14 @@ class GeneratedClassTest extends TestBase
{ {
$m = new TestMessage(); $m = new TestMessage();
$m->setOptionalNestedEnum(NestedEnum::ZERO); $m->setOptionalNestedEnum(NestedEnum::ZERO);
$this->assertTrue(true);
} }
public function testLegacyNestedEnum() public function testLegacyNestedEnum()
{ {
$m = new TestMessage(); $m = new TestMessage();
$m->setOptionalNestedEnum(\Foo\TestMessage_NestedEnum::ZERO); $m->setOptionalNestedEnum(\Foo\TestMessage_NestedEnum::ZERO);
$this->assertTrue(true);
} }
public function testLegacyTypehintWithNestedEnums() public function testLegacyTypehintWithNestedEnums()
...@@ -405,6 +407,7 @@ class GeneratedClassTest extends TestBase ...@@ -405,6 +407,7 @@ class GeneratedClassTest extends TestBase
$m = new TestMessage(); $m = new TestMessage();
$hex = hex2bin("ff"); $hex = hex2bin("ff");
$m->setOptionalBytes($hex); $m->setOptionalBytes($hex);
$this->assertTrue(true);
} }
######################################################### #########################################################
...@@ -709,6 +712,8 @@ class GeneratedClassTest extends TestBase ...@@ -709,6 +712,8 @@ class GeneratedClassTest extends TestBase
// test nested messages // test nested messages
$sub = new NoNamespaceMessage\NestedMessage(); $sub = new NoNamespaceMessage\NestedMessage();
$n->setNestedMessage($sub); $n->setNestedMessage($sub);
$this->assertTrue(true);
} }
public function testEnumWithoutNamespace() public function testEnumWithoutNamespace()
...@@ -718,6 +723,7 @@ class GeneratedClassTest extends TestBase ...@@ -718,6 +723,7 @@ class GeneratedClassTest extends TestBase
$repeatedNoNamespaceEnum = $m->getRepeatedNoNamespaceEnum(); $repeatedNoNamespaceEnum = $m->getRepeatedNoNamespaceEnum();
$repeatedNoNamespaceEnum[] = NoNameSpaceEnum::VALUE_A; $repeatedNoNamespaceEnum[] = NoNameSpaceEnum::VALUE_A;
$m->setRepeatedNoNamespaceEnum($repeatedNoNamespaceEnum); $m->setRepeatedNoNamespaceEnum($repeatedNoNamespaceEnum);
$this->assertTrue(true);
} }
######################################################### #########################################################
...@@ -1262,6 +1268,8 @@ class GeneratedClassTest extends TestBase ...@@ -1262,6 +1268,8 @@ class GeneratedClassTest extends TestBase
$m = \Upper_enum_value\NotAllowed::NULL; $m = \Upper_enum_value\NotAllowed::NULL;
$m = \Upper_enum_value\NotAllowed::VOID; $m = \Upper_enum_value\NotAllowed::VOID;
$m = \Upper_enum_value\NotAllowed::ITERABLE; $m = \Upper_enum_value\NotAllowed::ITERABLE;
$this->assertTrue(true);
} }
######################################################### #########################################################
...@@ -1297,6 +1305,7 @@ class GeneratedClassTest extends TestBase ...@@ -1297,6 +1305,7 @@ class GeneratedClassTest extends TestBase
{ {
$m = new testLowerCaseMessage(); $m = new testLowerCaseMessage();
$n = testLowerCaseEnum::VALUE; $n = testLowerCaseEnum::VALUE;
$this->assertTrue(true);
} }
######################################################### #########################################################
...@@ -1363,6 +1372,7 @@ class GeneratedClassTest extends TestBase ...@@ -1363,6 +1372,7 @@ class GeneratedClassTest extends TestBase
]); ]);
TestUtil::assertTestMessage($m); TestUtil::assertTestMessage($m);
$this->assertTrue(true);
} }
######################################################### #########################################################
......
...@@ -7,7 +7,7 @@ use Google\Protobuf\Internal\MapField; ...@@ -7,7 +7,7 @@ use Google\Protobuf\Internal\MapField;
use Foo\TestMessage; use Foo\TestMessage;
use Foo\TestMessage\Sub; use Foo\TestMessage\Sub;
class MapFieldTest extends PHPUnit_Framework_TestCase { class MapFieldTest extends \PHPUnit\Framework\TestCase {
######################################################### #########################################################
# Test int32 field. # Test int32 field.
......
...@@ -4,7 +4,7 @@ use Foo\TestMessage; ...@@ -4,7 +4,7 @@ use Foo\TestMessage;
use Foo\TestEnum; use Foo\TestEnum;
use Foo\TestMessage\Sub; use Foo\TestMessage\Sub;
class TestBase extends PHPUnit_Framework_TestCase class TestBase extends \PHPUnit\Framework\TestCase
{ {
public function setFields(TestMessage $m) public function setFields(TestMessage $m)
...@@ -338,5 +338,6 @@ class TestBase extends PHPUnit_Framework_TestCase ...@@ -338,5 +338,6 @@ class TestBase extends PHPUnit_Framework_TestCase
// This test is to avoid the warning of no test by php unit. // This test is to avoid the warning of no test by php unit.
public function testNone() public function testNone()
{ {
$this->assertTrue(true);
} }
} }
...@@ -48,6 +48,7 @@ class WellKnownTest extends TestBase { ...@@ -48,6 +48,7 @@ class WellKnownTest extends TestBase {
public function testImportDescriptorProto() public function testImportDescriptorProto()
{ {
$msg = new TestImportDescriptorProto(); $msg = new TestImportDescriptorProto();
$this->assertTrue(true);
} }
public function testAny() public function testAny()
......
...@@ -302,34 +302,25 @@ generate_php_test_proto() { ...@@ -302,34 +302,25 @@ generate_php_test_proto() {
use_php() { use_php() {
VERSION=$1 VERSION=$1
PHP=`which php` export PATH=/usr/local/php-${VERSION}/bin:$PATH
PHP_CONFIG=`which php-config` export CPLUS_INCLUDE_PATH=/usr/local/php-${VERSION}/include/php/main:/usr/local/php-${VERSION}/include/php/:$CPLUS_INCLUDE_PATH
PHPIZE=`which phpize` export C_INCLUDE_PATH=/usr/local/php-${VERSION}/include/php/main:/usr/local/php-${VERSION}/include/php/:$C_INCLUDE_PATH
ln -sfn "/usr/local/php-${VERSION}/bin/php" $PHP
ln -sfn "/usr/local/php-${VERSION}/bin/php-config" $PHP_CONFIG
ln -sfn "/usr/local/php-${VERSION}/bin/phpize" $PHPIZE
generate_php_test_proto generate_php_test_proto
} }
use_php_zts() { use_php_zts() {
VERSION=$1 VERSION=$1
PHP=`which php` export PATH=/usr/local/php-${VERSION}-zts/bin:$PATH
PHP_CONFIG=`which php-config` export CPLUS_INCLUDE_PATH=/usr/local/php-${VERSION}-zts/include/php/main:/usr/local/php-${VERSION}-zts/include/php/:$CPLUS_INCLUDE_PATH
PHPIZE=`which phpize` export C_INCLUDE_PATH=/usr/local/php-${VERSION}-zts/include/php/main:/usr/local/php-${VERSION}-zts/include/php/:$C_INCLUDE_PATH
ln -sfn "/usr/local/php-${VERSION}-zts/bin/php" $PHP
ln -sfn "/usr/local/php-${VERSION}-zts/bin/php-config" $PHP_CONFIG
ln -sfn "/usr/local/php-${VERSION}-zts/bin/phpize" $PHPIZE
generate_php_test_proto generate_php_test_proto
} }
use_php_bc() { use_php_bc() {
VERSION=$1 VERSION=$1
PHP=`which php` export PATH=/usr/local/php-${VERSION}-bc/bin:$PATH
PHP_CONFIG=`which php-config` export CPLUS_INCLUDE_PATH=/usr/local/php-${VERSION}-bc/include/php/main:/usr/local/php-${VERSION}-bc/include/php/:$CPLUS_INCLUDE_PATH
PHPIZE=`which phpize` export C_INCLUDE_PATH=/usr/local/php-${VERSION}-bc/include/php/main:/usr/local/php-${VERSION}-bc/include/php/:$C_INCLUDE_PATH
ln -sfn "/usr/local/php-${VERSION}-bc/bin/php" $PHP
ln -sfn "/usr/local/php-${VERSION}-bc/bin/php-config" $PHP_CONFIG
ln -sfn "/usr/local/php-${VERSION}-bc/bin/phpize" $PHPIZE
generate_php_test_proto generate_php_test_proto
} }
...@@ -338,9 +329,8 @@ build_php5.5() { ...@@ -338,9 +329,8 @@ build_php5.5() {
pushd php pushd php
rm -rf vendor rm -rf vendor
cp -r /usr/local/vendor-5.5 vendor composer update
wget https://phar.phpunit.de/phpunit-4.8.0.phar -O /usr/bin/phpunit ./vendor/bin/phpunit
phpunit
popd popd
pushd conformance pushd conformance
make test_php make test_php
...@@ -349,7 +339,6 @@ build_php5.5() { ...@@ -349,7 +339,6 @@ build_php5.5() {
build_php5.5_c() { build_php5.5_c() {
use_php 5.5 use_php 5.5
wget https://phar.phpunit.de/phpunit-4.8.0.phar -O /usr/bin/phpunit
pushd php/tests pushd php/tests
/bin/bash ./test.sh 5.5 /bin/bash ./test.sh 5.5
popd popd
...@@ -361,7 +350,6 @@ build_php5.5_c() { ...@@ -361,7 +350,6 @@ build_php5.5_c() {
build_php5.5_zts_c() { build_php5.5_zts_c() {
use_php_zts 5.5 use_php_zts 5.5
wget https://phar.phpunit.de/phpunit-4.8.0.phar -O /usr/bin/phpunit
cd php/tests && /bin/bash ./test.sh 5.5-zts && cd ../.. cd php/tests && /bin/bash ./test.sh 5.5-zts && cd ../..
# TODO(teboring): Add it back # TODO(teboring): Add it back
# pushd conformance # pushd conformance
...@@ -373,9 +361,8 @@ build_php5.6() { ...@@ -373,9 +361,8 @@ build_php5.6() {
use_php 5.6 use_php 5.6
pushd php pushd php
rm -rf vendor rm -rf vendor
cp -r /usr/local/vendor-5.6 vendor composer update
wget https://phar.phpunit.de/phpunit-5.7.0.phar -O /usr/bin/phpunit ./vendor/bin/phpunit
phpunit
popd popd
pushd conformance pushd conformance
make test_php make test_php
...@@ -384,7 +371,6 @@ build_php5.6() { ...@@ -384,7 +371,6 @@ build_php5.6() {
build_php5.6_c() { build_php5.6_c() {
use_php 5.6 use_php 5.6
wget https://phar.phpunit.de/phpunit-5.7.0.phar -O /usr/bin/phpunit
cd php/tests && /bin/bash ./test.sh 5.6 && cd ../.. cd php/tests && /bin/bash ./test.sh 5.6 && cd ../..
# TODO(teboring): Add it back # TODO(teboring): Add it back
# pushd conformance # pushd conformance
...@@ -394,7 +380,6 @@ build_php5.6_c() { ...@@ -394,7 +380,6 @@ build_php5.6_c() {
build_php5.6_zts_c() { build_php5.6_zts_c() {
use_php_zts 5.6 use_php_zts 5.6
wget https://phar.phpunit.de/phpunit-5.7.0.phar -O /usr/bin/phpunit
cd php/tests && /bin/bash ./test.sh 5.6-zts && cd ../.. cd php/tests && /bin/bash ./test.sh 5.6-zts && cd ../..
# TODO(teboring): Add it back # TODO(teboring): Add it back
# pushd conformance # pushd conformance
...@@ -431,9 +416,8 @@ build_php7.0() { ...@@ -431,9 +416,8 @@ build_php7.0() {
use_php 7.0 use_php 7.0
pushd php pushd php
rm -rf vendor rm -rf vendor
cp -r /usr/local/vendor-7.0 vendor composer update
wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit ./vendor/bin/phpunit
phpunit
popd popd
pushd conformance pushd conformance
make test_php make test_php
...@@ -442,7 +426,6 @@ build_php7.0() { ...@@ -442,7 +426,6 @@ build_php7.0() {
build_php7.0_c() { build_php7.0_c() {
use_php 7.0 use_php 7.0
wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit
cd php/tests && /bin/bash ./test.sh 7.0 && cd ../.. cd php/tests && /bin/bash ./test.sh 7.0 && cd ../..
# TODO(teboring): Add it back # TODO(teboring): Add it back
# pushd conformance # pushd conformance
...@@ -452,7 +435,6 @@ build_php7.0_c() { ...@@ -452,7 +435,6 @@ build_php7.0_c() {
build_php7.0_zts_c() { build_php7.0_zts_c() {
use_php_zts 7.0 use_php_zts 7.0
wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit
cd php/tests && /bin/bash ./test.sh 7.0-zts && cd ../.. cd php/tests && /bin/bash ./test.sh 7.0-zts && cd ../..
# TODO(teboring): Add it back. # TODO(teboring): Add it back.
# pushd conformance # pushd conformance
...@@ -494,9 +476,8 @@ build_php7.1() { ...@@ -494,9 +476,8 @@ build_php7.1() {
use_php 7.1 use_php 7.1
pushd php pushd php
rm -rf vendor rm -rf vendor
cp -r /usr/local/vendor-7.1 vendor composer update
wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit ./vendor/bin/phpunit
phpunit
popd popd
pushd conformance pushd conformance
make test_php make test_php
...@@ -506,7 +487,6 @@ build_php7.1() { ...@@ -506,7 +487,6 @@ build_php7.1() {
build_php7.1_c() { build_php7.1_c() {
ENABLE_CONFORMANCE_TEST=$1 ENABLE_CONFORMANCE_TEST=$1
use_php 7.1 use_php 7.1
wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit
cd php/tests && /bin/bash ./test.sh 7.1 && cd ../.. cd php/tests && /bin/bash ./test.sh 7.1 && cd ../..
if [ "$ENABLE_CONFORMANCE_TEST" = "true" ] if [ "$ENABLE_CONFORMANCE_TEST" = "true" ]
then then
...@@ -518,7 +498,6 @@ build_php7.1_c() { ...@@ -518,7 +498,6 @@ build_php7.1_c() {
build_php7.1_zts_c() { build_php7.1_zts_c() {
use_php_zts 7.1 use_php_zts 7.1
wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit
cd php/tests && /bin/bash ./test.sh 7.1-zts && cd ../.. cd php/tests && /bin/bash ./test.sh 7.1-zts && cd ../..
pushd conformance pushd conformance
# make test_php_c # make test_php_c
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment