diff options
author | Loo Rong Jie <loorongjie@gmail.com> | 2018-06-21 11:29:04 +0800 |
---|---|---|
committer | Jakob Buchgraber <buchgr@google.com> | 2018-07-09 16:28:56 +0200 |
commit | 6fd4e0edd4de22dec9eda13dc0b29214f2ca117e (patch) | |
tree | e05b713ab4eceb88e6686e34e2a98426b16009bc /third_party/protobuf/3.4.0/php/tests | |
parent | 868060b2925a98a22c4a2e760dd38da0bef6146c (diff) |
Update protobuf to 3.6.0. Fixes #5439
Diffstat (limited to 'third_party/protobuf/3.4.0/php/tests')
27 files changed, 0 insertions, 5862 deletions
diff --git a/third_party/protobuf/3.4.0/php/tests/array_test.php b/third_party/protobuf/3.4.0/php/tests/array_test.php deleted file mode 100644 index 1a26d72a88..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/array_test.php +++ /dev/null @@ -1,554 +0,0 @@ -<?php - -require_once('test_util.php'); - -use Google\Protobuf\Internal\RepeatedField; -use Google\Protobuf\Internal\GPBType; -use Foo\TestMessage; -use Foo\TestMessage_Sub; - -class RepeatedFieldTest extends PHPUnit_Framework_TestCase -{ - - ######################################################### - # Test int32 field. - ######################################################### - - public function testInt32() - { - $arr = new RepeatedField(GPBType::INT32); - - // Test append. - $arr[] = MAX_INT32; - $this->assertSame(MAX_INT32, $arr[0]); - $arr[] = MIN_INT32; - $this->assertSame(MIN_INT32, $arr[1]); - - $arr[] = 1.1; - $this->assertSame(1, $arr[2]); - $arr[] = MAX_INT32_FLOAT; - $this->assertSame(MAX_INT32, $arr[3]); - $arr[] = MAX_INT32_FLOAT; - $this->assertSame(MAX_INT32, $arr[4]); - - $arr[] = '2'; - $this->assertSame(2, $arr[5]); - $arr[] = '3.1'; - $this->assertSame(3, $arr[6]); - $arr[] = MAX_INT32_STRING; - $this->assertSame(MAX_INT32, $arr[7]); - - $this->assertEquals(8, count($arr)); - - for ($i = 0; $i < count($arr); $i++) { - $arr[$i] = 0; - $this->assertSame(0, $arr[$i]); - } - - // Test set. - $arr[0] = MAX_INT32; - $this->assertSame(MAX_INT32, $arr[0]); - $arr[1] = MIN_INT32; - $this->assertSame(MIN_INT32, $arr[1]); - - $arr[2] = 1.1; - $this->assertSame(1, $arr[2]); - $arr[3] = MAX_INT32_FLOAT; - $this->assertSame(MAX_INT32, $arr[3]); - $arr[4] = MAX_INT32_FLOAT; - $this->assertSame(MAX_INT32, $arr[4]); - - $arr[5] = '2'; - $this->assertSame(2, $arr[5]); - $arr[6] = '3.1'; - $this->assertSame(3, $arr[6]); - $arr[7] = MAX_INT32_STRING; - $this->assertSame(MAX_INT32, $arr[7]); - - // Test foreach. - $arr = new RepeatedField(GPBType::INT32); - for ($i = 0; $i < 3; $i++) { - $arr[] = $i; - } - $i = 0; - foreach ($arr as $val) { - $this->assertSame($i++, $val); - } - $this->assertSame(3, $i); - } - - ######################################################### - # Test uint32 field. - ######################################################### - - public function testUint32() - { - $arr = new RepeatedField(GPBType::UINT32); - - // Test append. - $arr[] = MAX_UINT32; - $this->assertSame(-1, $arr[0]); - $arr[] = -1; - $this->assertSame(-1, $arr[1]); - $arr[] = MIN_UINT32; - $this->assertSame(MIN_UINT32, $arr[2]); - - $arr[] = 1.1; - $this->assertSame(1, $arr[3]); - $arr[] = MAX_UINT32_FLOAT; - $this->assertSame(-1, $arr[4]); - $arr[] = -1.0; - $this->assertSame(-1, $arr[5]); - $arr[] = MIN_UINT32_FLOAT; - $this->assertSame(MIN_UINT32, $arr[6]); - - $arr[] = '2'; - $this->assertSame(2, $arr[7]); - $arr[] = '3.1'; - $this->assertSame(3, $arr[8]); - $arr[] = MAX_UINT32_STRING; - $this->assertSame(-1, $arr[9]); - $arr[] = '-1.0'; - $this->assertSame(-1, $arr[10]); - $arr[] = MIN_UINT32_STRING; - $this->assertSame(MIN_UINT32, $arr[11]); - - $this->assertEquals(12, count($arr)); - - for ($i = 0; $i < count($arr); $i++) { - $arr[$i] = 0; - $this->assertSame(0, $arr[$i]); - } - - // Test set. - $arr[0] = MAX_UINT32; - $this->assertSame(-1, $arr[0]); - $arr[1] = -1; - $this->assertSame(-1, $arr[1]); - $arr[2] = MIN_UINT32; - $this->assertSame(MIN_UINT32, $arr[2]); - - $arr[3] = 1.1; - $this->assertSame(1, $arr[3]); - $arr[4] = MAX_UINT32_FLOAT; - $this->assertSame(-1, $arr[4]); - $arr[5] = -1.0; - $this->assertSame(-1, $arr[5]); - $arr[6] = MIN_UINT32_FLOAT; - $this->assertSame(MIN_UINT32, $arr[6]); - - $arr[7] = '2'; - $this->assertSame(2, $arr[7]); - $arr[8] = '3.1'; - $this->assertSame(3, $arr[8]); - $arr[9] = MAX_UINT32_STRING; - $this->assertSame(-1, $arr[9]); - $arr[10] = '-1.0'; - $this->assertSame(-1, $arr[10]); - $arr[11] = MIN_UINT32_STRING; - $this->assertSame(MIN_UINT32, $arr[11]); - } - - ######################################################### - # Test int64 field. - ######################################################### - - public function testInt64() - { - $arr = new RepeatedField(GPBType::INT64); - - // Test append. - $arr[] = MAX_INT64; - $arr[] = MIN_INT64; - $arr[] = 1.1; - $arr[] = '2'; - $arr[] = '3.1'; - $arr[] = MAX_INT64_STRING; - $arr[] = MIN_INT64_STRING; - if (PHP_INT_SIZE == 4) { - $this->assertSame(MAX_INT64, $arr[0]); - $this->assertSame(MIN_INT64, $arr[1]); - $this->assertSame('1', $arr[2]); - $this->assertSame('2', $arr[3]); - $this->assertSame('3', $arr[4]); - $this->assertSame(MAX_INT64_STRING, $arr[5]); - $this->assertSame(MIN_INT64_STRING, $arr[6]); - } else { - $this->assertSame(MAX_INT64, $arr[0]); - $this->assertSame(MIN_INT64, $arr[1]); - $this->assertSame(1, $arr[2]); - $this->assertSame(2, $arr[3]); - $this->assertSame(3, $arr[4]); - $this->assertSame(MAX_INT64, $arr[5]); - $this->assertSame(MIN_INT64, $arr[6]); - } - - - $this->assertEquals(7, count($arr)); - - for ($i = 0; $i < count($arr); $i++) { - $arr[$i] = 0; - if (PHP_INT_SIZE == 4) { - $this->assertSame('0', $arr[$i]); - } else { - $this->assertSame(0, $arr[$i]); - } - } - - // Test set. - $arr[0] = MAX_INT64; - $arr[1] = MIN_INT64; - $arr[2] = 1.1; - $arr[3] = '2'; - $arr[4] = '3.1'; - $arr[5] = MAX_INT64_STRING; - $arr[6] = MIN_INT64_STRING; - - if (PHP_INT_SIZE == 4) { - $this->assertSame(MAX_INT64_STRING, $arr[0]); - $this->assertSame(MIN_INT64_STRING, $arr[1]); - $this->assertSame('1', $arr[2]); - $this->assertSame('2', $arr[3]); - $this->assertSame('3', $arr[4]); - $this->assertSame(MAX_INT64_STRING, $arr[5]); - $this->assertEquals(MIN_INT64_STRING, $arr[6]); - } else { - $this->assertSame(MAX_INT64, $arr[0]); - $this->assertSame(MIN_INT64, $arr[1]); - $this->assertSame(1, $arr[2]); - $this->assertSame(2, $arr[3]); - $this->assertSame(3, $arr[4]); - $this->assertSame(MAX_INT64, $arr[5]); - $this->assertEquals(MIN_INT64, $arr[6]); - } - } - - ######################################################### - # Test uint64 field. - ######################################################### - - public function testUint64() - { - $arr = new RepeatedField(GPBType::UINT64); - - // Test append. - $arr[] = MAX_UINT64; - $arr[] = 1.1; - $arr[] = '2'; - $arr[] = '3.1'; - $arr[] = MAX_UINT64_STRING; - - if (PHP_INT_SIZE == 4) { - $this->assertSame(MAX_UINT64_STRING, $arr[0]); - $this->assertSame('1', $arr[1]); - $this->assertSame('2', $arr[2]); - $this->assertSame('3', $arr[3]); - $this->assertSame(MAX_UINT64_STRING, $arr[4]); - } else { - $this->assertSame(MAX_UINT64, $arr[0]); - $this->assertSame(1, $arr[1]); - $this->assertSame(2, $arr[2]); - $this->assertSame(3, $arr[3]); - $this->assertSame(MAX_UINT64, $arr[4]); - $this->assertSame(5, count($arr)); - } - - $this->assertSame(5, count($arr)); - - for ($i = 0; $i < count($arr); $i++) { - $arr[$i] = 0; - if (PHP_INT_SIZE == 4) { - $this->assertSame('0', $arr[$i]); - } else { - $this->assertSame(0, $arr[$i]); - } - } - - // Test set. - $arr[0] = MAX_UINT64; - $arr[1] = 1.1; - $arr[2] = '2'; - $arr[3] = '3.1'; - $arr[4] = MAX_UINT64_STRING; - - if (PHP_INT_SIZE == 4) { - $this->assertSame(MAX_UINT64_STRING, $arr[0]); - $this->assertSame('1', $arr[1]); - $this->assertSame('2', $arr[2]); - $this->assertSame('3', $arr[3]); - $this->assertSame(MAX_UINT64_STRING, $arr[4]); - } else { - $this->assertSame(MAX_UINT64, $arr[0]); - $this->assertSame(1, $arr[1]); - $this->assertSame(2, $arr[2]); - $this->assertSame(3, $arr[3]); - $this->assertSame(MAX_UINT64, $arr[4]); - } - } - - ######################################################### - # Test float field. - ######################################################### - - public function testFloat() - { - $arr = new RepeatedField(GPBType::FLOAT); - - // Test append. - $arr[] = 1; - $this->assertEquals(1.0, $arr[0], '', MAX_FLOAT_DIFF); - - $arr[] = 1.1; - $this->assertEquals(1.1, $arr[1], '', MAX_FLOAT_DIFF); - - $arr[] = '2'; - $this->assertEquals(2.0, $arr[2], '', MAX_FLOAT_DIFF); - $arr[] = '3.1'; - $this->assertEquals(3.1, $arr[3], '', MAX_FLOAT_DIFF); - - $this->assertEquals(4, count($arr)); - - for ($i = 0; $i < count($arr); $i++) { - $arr[$i] = 0; - $this->assertSame(0.0, $arr[$i]); - } - - // Test set. - $arr[0] = 1; - $this->assertEquals(1.0, $arr[0], '', MAX_FLOAT_DIFF); - - $arr[1] = 1.1; - $this->assertEquals(1.1, $arr[1], '', MAX_FLOAT_DIFF); - - $arr[2] = '2'; - $this->assertEquals(2.0, $arr[2], '', MAX_FLOAT_DIFF); - $arr[3] = '3.1'; - $this->assertEquals(3.1, $arr[3], '', MAX_FLOAT_DIFF); - } - - ######################################################### - # Test double field. - ######################################################### - - public function testDouble() - { - $arr = new RepeatedField(GPBType::DOUBLE); - - // Test append. - $arr[] = 1; - $this->assertEquals(1.0, $arr[0], '', MAX_FLOAT_DIFF); - - $arr[] = 1.1; - $this->assertEquals(1.1, $arr[1], '', MAX_FLOAT_DIFF); - - $arr[] = '2'; - $this->assertEquals(2.0, $arr[2], '', MAX_FLOAT_DIFF); - $arr[] = '3.1'; - $this->assertEquals(3.1, $arr[3], '', MAX_FLOAT_DIFF); - - $this->assertEquals(4, count($arr)); - - for ($i = 0; $i < count($arr); $i++) { - $arr[$i] = 0; - $this->assertSame(0.0, $arr[$i]); - } - - // Test set. - $arr[0] = 1; - $this->assertEquals(1.0, $arr[0], '', MAX_FLOAT_DIFF); - - $arr[1] = 1.1; - $this->assertEquals(1.1, $arr[1], '', MAX_FLOAT_DIFF); - - $arr[2] = '2'; - $this->assertEquals(2.0, $arr[2], '', MAX_FLOAT_DIFF); - $arr[3] = '3.1'; - $this->assertEquals(3.1, $arr[3], '', MAX_FLOAT_DIFF); - } - - ######################################################### - # Test bool field. - ######################################################### - - public function testBool() - { - $arr = new RepeatedField(GPBType::BOOL); - - // Test append. - $arr[] = true; - $this->assertSame(true, $arr[0]); - - $arr[] = -1; - $this->assertSame(true, $arr[1]); - - $arr[] = 1.1; - $this->assertSame(true, $arr[2]); - - $arr[] = ''; - $this->assertSame(false, $arr[3]); - - $this->assertEquals(4, count($arr)); - - for ($i = 0; $i < count($arr); $i++) { - $arr[$i] = 0; - $this->assertSame(false, $arr[$i]); - } - - // Test set. - $arr[0] = true; - $this->assertSame(true, $arr[0]); - - $arr[1] = -1; - $this->assertSame(true, $arr[1]); - - $arr[2] = 1.1; - $this->assertSame(true, $arr[2]); - - $arr[3] = ''; - $this->assertSame(false, $arr[3]); - } - - ######################################################### - # Test string field. - ######################################################### - - public function testString() - { - $arr = new RepeatedField(GPBType::STRING); - - // Test append. - $arr[] = 'abc'; - $this->assertSame('abc', $arr[0]); - - $arr[] = 1; - $this->assertSame('1', $arr[1]); - - $arr[] = 1.1; - $this->assertSame('1.1', $arr[2]); - - $arr[] = true; - $this->assertSame('1', $arr[3]); - - $this->assertEquals(4, count($arr)); - - for ($i = 0; $i < count($arr); $i++) { - $arr[$i] = ''; - $this->assertSame('', $arr[$i]); - } - - // Test set. - $arr[0] = 'abc'; - $this->assertSame('abc', $arr[0]); - - $arr[1] = 1; - $this->assertSame('1', $arr[1]); - - $arr[2] = 1.1; - $this->assertSame('1.1', $arr[2]); - - $arr[3] = true; - $this->assertSame('1', $arr[3]); - } - - ######################################################### - # Test message field. - ######################################################### - - public function testMessage() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - - // Test append. - $sub_m = new TestMessage_Sub(); - $sub_m->setA(1); - $arr[] = $sub_m; - $this->assertSame(1, $arr[0]->getA()); - - $this->assertEquals(1, count($arr)); - - // Test set. - $sub_m = new TestMessage_Sub(); - $sub_m->setA(2); - $arr[0] = $sub_m; - $this->assertSame(2, $arr[0]->getA()); - - // Test foreach. - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - for ($i = 0; $i < 3; $i++) { - $arr[] = new TestMessage_Sub(); - $arr[$i]->setA($i); - } - $i = 0; - foreach ($arr as $val) { - $this->assertSame($i++, $val->getA()); - } - $this->assertSame(3, $i); - } - - ######################################################### - # Test offset type - ######################################################### - - public function testOffset() - { - $arr = new RepeatedField(GPBType::INT32); - $arr[] = 0; - - $arr[0] = 1; - $this->assertSame(1, $arr[0]); - $this->assertSame(1, count($arr)); - - $arr['0'] = 2; - $this->assertSame(2, $arr['0']); - $this->assertSame(2, $arr[0]); - $this->assertSame(1, count($arr)); - - $arr[0.0] = 3; - $this->assertSame(3, $arr[0.0]); - $this->assertSame(1, count($arr)); - } - - public function testInsertRemoval() - { - $arr = new RepeatedField(GPBType::INT32); - - $arr[] = 0; - $arr[] = 1; - $arr[] = 2; - $this->assertSame(3, count($arr)); - - unset($arr[2]); - $this->assertSame(2, count($arr)); - $this->assertSame(0, $arr[0]); - $this->assertSame(1, $arr[1]); - - $arr[] = 3; - $this->assertSame(3, count($arr)); - $this->assertSame(0, $arr[0]); - $this->assertSame(1, $arr[1]); - $this->assertSame(3, $arr[2]); - } - - ######################################################### - # Test memory leak - ######################################################### - - public function testCycleLeak() - { - gc_collect_cycles(); - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage::class); - $arr[] = new TestMessage; - $arr[0]->SetRepeatedRecursive($arr); - - // Clean up memory before test. - gc_collect_cycles(); - $start = memory_get_usage(); - unset($arr); - - // Explicitly trigger garbage collection. - gc_collect_cycles(); - - $end = memory_get_usage(); - $this->assertLessThan($start, $end); - } -} diff --git a/third_party/protobuf/3.4.0/php/tests/autoload.php b/third_party/protobuf/3.4.0/php/tests/autoload.php deleted file mode 100755 index 0a917fc51a..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/autoload.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php - -function getGeneratedFiles($dir, &$results = array()) -{ - $files = scandir($dir); - - foreach ($files as $key => $value) { - $path = realpath($dir.DIRECTORY_SEPARATOR.$value); - if (!is_dir($path)) { - $results[] = $path; - } else if ($value != "." && $value != "..") { - getGeneratedFiles($path, $results); - } - } - return $results; -} - -foreach (getGeneratedFiles("generated") as $filename) -{ - if (!is_dir($filename)) { - include_once $filename; - } - -} - diff --git a/third_party/protobuf/3.4.0/php/tests/compatibility_test.sh b/third_party/protobuf/3.4.0/php/tests/compatibility_test.sh deleted file mode 100755 index 6f1e49000b..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/compatibility_test.sh +++ /dev/null @@ -1,141 +0,0 @@ -#!/bin/bash - -function use_php() { - VERSION=$1 - PHP=`which php` - PHP_CONFIG=`which php-config` - PHPIZE=`which phpize` - 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 -} - -function generate_proto() { - PROTOC1=$1 - PROTOC2=$2 - - rm -rf generated - mkdir generated - - $PROTOC1 --php_out=generated proto/test_include.proto - $PROTOC2 --php_out=generated proto/test.proto proto/test_no_namespace.proto proto/test_prefix.proto - pushd ../../src - $PROTOC2 --php_out=../php/tests/generated google/protobuf/empty.proto - $PROTOC2 --php_out=../php/tests/generated -I../php/tests -I. ../php/tests/proto/test_import_descriptor_proto.proto - popd -} - -# Remove tests to expect error. These were added to API tests by mistake. -function remove_error_test() { - local TEMPFILE=`tempfile` - cat $1 | \ - awk -v file=`basename $1` -v dir=`basename $(dirname $1)` ' - BEGIN { - show = 1 - } - /@expectedException PHPUnit_Framework_Error/ { show = 0; next; } - / *\*\// { print; next; } - / *}/ { - if (!show) { - show = 1; - next; - } - } - show { print } - ' > $TEMPFILE - cp $TEMPFILE $1 -} - -set -ex - -# Change to the script's directory. -cd $(dirname $0) - -# The old version of protobuf that we are testing compatibility against. -case "$1" in - ""|3.3.0) - OLD_VERSION=3.3.0 - OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.3.0/protoc-3.3.0-linux-x86_64.exe - ;; - *) - echo "[ERROR]: Unknown version number: $1" - exit 1 - ;; -esac - -# Extract the latest protobuf version number. -VERSION_NUMBER=`grep "PHP_PROTOBUF_VERSION" ../ext/google/protobuf/protobuf.h | sed "s|#define PHP_PROTOBUF_VERSION \"\(.*\)\"|\1|"` - -echo "Running compatibility tests between $VERSION_NUMBER and $OLD_VERSION" - -# Check protoc -[ -f ../../src/protoc ] || { - echo "[ERROR]: Please build protoc first." - exit 1 -} - -# Download old test. -rm -rf protobuf -git clone https://github.com/google/protobuf.git -pushd protobuf -git checkout v$OLD_VERSION -popd - -# Build and copy the new runtime -use_php 5.5 -pushd ../ext/google/protobuf -make clean || true -phpize && ./configure && make -popd - -rm -rf protobuf/php/ext -rm -rf protobuf/php/src -cp -r ../ext protobuf/php/ext/ -cp -r ../src protobuf/php/src/ - -# Download old version protoc compiler (for linux) -wget $OLD_VERSION_PROTOC -O old_protoc -chmod +x old_protoc - -NEW_PROTOC=`pwd`/../../src/protoc -OLD_PROTOC=`pwd`/old_protoc -cd protobuf/php -cp -r /usr/local/vendor-5.5 vendor -wget https://phar.phpunit.de/phpunit-4.8.0.phar -O /usr/bin/phpunit - -# Remove implementation detail tests. -tests=( array_test.php encode_decode_test.php generated_class_test.php map_field_test.php well_known_test.php ) -sed -i.bak '/php_implementation_test.php/d' phpunit.xml -for t in "${tests[@]}" -do - remove_error_test tests/$t -done - -cd tests - -# Test A.1: -# proto set 1: use old version -# proto set 2 which may import protos in set 1: use old version -generate_proto $OLD_PROTOC $OLD_PROTOC -./test.sh -pushd .. -phpunit -popd - -# Test A.2: -# proto set 1: use new version -# proto set 2 which may import protos in set 1: use old version -generate_proto $NEW_PROTOC $OLD_PROTOC -./test.sh -pushd .. -phpunit -popd - -# Test A.3: -# proto set 1: use old version -# proto set 2 which may import protos in set 1: use new version -generate_proto $OLD_PROTOC $NEW_PROTOC -./test.sh -pushd .. -phpunit -popd diff --git a/third_party/protobuf/3.4.0/php/tests/descriptors_test.php b/third_party/protobuf/3.4.0/php/tests/descriptors_test.php deleted file mode 100644 index 17e8a4f2fd..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/descriptors_test.php +++ /dev/null @@ -1,246 +0,0 @@ -<?php - -require_once('generated/Descriptors/TestDescriptorsEnum.php'); -require_once('generated/Descriptors/TestDescriptorsMessage.php'); -require_once('test_base.php'); -require_once('test_util.php'); - -use Google\Protobuf\DescriptorPool; -use Google\Protobuf\Internal\RepeatedField; -use Google\Protobuf\Internal\MapField; -use Descriptors\TestDescriptorsEnum; -use Descriptors\TestDescriptorsMessage; -use Descriptors\TestDescriptorsMessage_Sub; - -class DescriptorsTest extends TestBase -{ - - // Redefine these here for compatibility with c extension - const GPBLABEL_OPTIONAL = 1; - const GPBLABEL_REQUIRED = 2; - const GPBLABEL_REPEATED = 3; - - const GPBTYPE_DOUBLE = 1; - const GPBTYPE_FLOAT = 2; - const GPBTYPE_INT64 = 3; - const GPBTYPE_UINT64 = 4; - const GPBTYPE_INT32 = 5; - const GPBTYPE_FIXED64 = 6; - const GPBTYPE_FIXED32 = 7; - const GPBTYPE_BOOL = 8; - const GPBTYPE_STRING = 9; - const GPBTYPE_GROUP = 10; - const GPBTYPE_MESSAGE = 11; - const GPBTYPE_BYTES = 12; - const GPBTYPE_UINT32 = 13; - const GPBTYPE_ENUM = 14; - const GPBTYPE_SFIXED32 = 15; - const GPBTYPE_SFIXED64 = 16; - const GPBTYPE_SINT32 = 17; - const GPBTYPE_SINT64 = 18; - - ######################################################### - # Test descriptor pool. - ######################################################### - - public function testDescriptorPool() - { - $pool = DescriptorPool::getGeneratedPool(); - - $desc = $pool->getDescriptorByClassName(get_class(new TestDescriptorsMessage())); - $this->assertInstanceOf('\Google\Protobuf\Descriptor', $desc); - - $enumDesc = $pool->getEnumDescriptorByClassName(get_class(new TestDescriptorsEnum())); - $this->assertInstanceOf('\Google\Protobuf\EnumDescriptor', $enumDesc); - } - - public function testDescriptorPoolIncorrectArgs() - { - $pool = DescriptorPool::getGeneratedPool(); - - $desc = $pool->getDescriptorByClassName('NotAClass'); - $this->assertNull($desc); - - $desc = $pool->getDescriptorByClassName(get_class(new TestDescriptorsEnum())); - $this->assertNull($desc); - - $enumDesc = $pool->getEnumDescriptorByClassName(get_class(new TestDescriptorsMessage())); - $this->assertNull($enumDesc); - } - - ######################################################### - # Test descriptor. - ######################################################### - - public function testDescriptor() - { - $pool = DescriptorPool::getGeneratedPool(); - $class = get_class(new TestDescriptorsMessage()); - $this->assertSame('Descriptors\TestDescriptorsMessage', $class); - $desc = $pool->getDescriptorByClassName($class); - - $this->assertSame('descriptors.TestDescriptorsMessage', $desc->getFullName()); - $this->assertSame($class, $desc->getClass()); - - $this->assertInstanceOf('\Google\Protobuf\FieldDescriptor', $desc->getField(0)); - $this->assertSame(7, $desc->getFieldCount()); - - $this->assertInstanceOf('\Google\Protobuf\OneofDescriptor', $desc->getOneofDecl(0)); - $this->assertSame(1, $desc->getOneofDeclCount()); - } - - ######################################################### - # Test enum descriptor. - ######################################################### - - public function testEnumDescriptor() - { - // WARNINIG - we need to do this so that TestDescriptorsEnum is registered!!? - new TestDescriptorsMessage(); - - $pool = DescriptorPool::getGeneratedPool(); - - $enumDesc = $pool->getEnumDescriptorByClassName(get_class(new TestDescriptorsEnum())); - - // Build map of enum values - $enumDescMap = []; - for ($i = 0; $i < $enumDesc->getValueCount(); $i++) { - $enumValueDesc = $enumDesc->getValue($i); - $this->assertInstanceOf('\Google\Protobuf\EnumValueDescriptor', $enumValueDesc); - $enumDescMap[$enumValueDesc->getNumber()] = $enumValueDesc->getName(); - } - - $this->assertSame('ZERO', $enumDescMap[0]); - $this->assertSame('ONE', $enumDescMap[1]); - - $this->assertSame(2, $enumDesc->getValueCount()); - } - - ######################################################### - # Test field descriptor. - ######################################################### - - public function testFieldDescriptor() - { - $pool = DescriptorPool::getGeneratedPool(); - $desc = $pool->getDescriptorByClassName(get_class(new TestDescriptorsMessage())); - - $fieldDescMap = $this->buildFieldMap($desc); - - // Optional int field - $fieldDesc = $fieldDescMap[1]; - $this->assertSame('optional_int32', $fieldDesc->getName()); - $this->assertSame(1, $fieldDesc->getNumber()); - $this->assertSame(self::GPBLABEL_OPTIONAL, $fieldDesc->getLabel()); - $this->assertSame(self::GPBTYPE_INT32, $fieldDesc->getType()); - $this->assertFalse($fieldDesc->isMap()); - - // Optional enum field - $fieldDesc = $fieldDescMap[16]; - $this->assertSame('optional_enum', $fieldDesc->getName()); - $this->assertSame(16, $fieldDesc->getNumber()); - $this->assertSame(self::GPBLABEL_OPTIONAL, $fieldDesc->getLabel()); - $this->assertSame(self::GPBTYPE_ENUM, $fieldDesc->getType()); - $this->assertInstanceOf('\Google\Protobuf\EnumDescriptor', $fieldDesc->getEnumType()); - $this->assertFalse($fieldDesc->isMap()); - - // Optional message field - $fieldDesc = $fieldDescMap[17]; - $this->assertSame('optional_message', $fieldDesc->getName()); - $this->assertSame(17, $fieldDesc->getNumber()); - $this->assertSame(self::GPBLABEL_OPTIONAL, $fieldDesc->getLabel()); - $this->assertSame(self::GPBTYPE_MESSAGE, $fieldDesc->getType()); - $this->assertInstanceOf('\Google\Protobuf\Descriptor', $fieldDesc->getMessageType()); - $this->assertFalse($fieldDesc->isMap()); - - // Repeated int field - $fieldDesc = $fieldDescMap[31]; - $this->assertSame('repeated_int32', $fieldDesc->getName()); - $this->assertSame(31, $fieldDesc->getNumber()); - $this->assertSame(self::GPBLABEL_REPEATED, $fieldDesc->getLabel()); - $this->assertSame(self::GPBTYPE_INT32, $fieldDesc->getType()); - $this->assertFalse($fieldDesc->isMap()); - - // Repeated message field - $fieldDesc = $fieldDescMap[47]; - $this->assertSame('repeated_message', $fieldDesc->getName()); - $this->assertSame(47, $fieldDesc->getNumber()); - $this->assertSame(self::GPBLABEL_REPEATED, $fieldDesc->getLabel()); - $this->assertSame(self::GPBTYPE_MESSAGE, $fieldDesc->getType()); - $this->assertInstanceOf('\Google\Protobuf\Descriptor', $fieldDesc->getMessageType()); - $this->assertFalse($fieldDesc->isMap()); - - // Oneof int field - // Tested further in testOneofDescriptor() - $fieldDesc = $fieldDescMap[51]; - $this->assertSame('oneof_int32', $fieldDesc->getName()); - $this->assertSame(51, $fieldDesc->getNumber()); - $this->assertSame(self::GPBLABEL_OPTIONAL, $fieldDesc->getLabel()); - $this->assertSame(self::GPBTYPE_INT32, $fieldDesc->getType()); - $this->assertFalse($fieldDesc->isMap()); - - // Map int-enum field - $fieldDesc = $fieldDescMap[71]; - $this->assertSame('map_int32_enum', $fieldDesc->getName()); - $this->assertSame(71, $fieldDesc->getNumber()); - $this->assertSame(self::GPBLABEL_REPEATED, $fieldDesc->getLabel()); - $this->assertSame(self::GPBTYPE_MESSAGE, $fieldDesc->getType()); - $this->assertTrue($fieldDesc->isMap()); - $mapDesc = $fieldDesc->getMessageType(); - $this->assertSame('descriptors.TestDescriptorsMessage.MapInt32EnumEntry', $mapDesc->getFullName()); - $this->assertSame(self::GPBTYPE_INT32, $mapDesc->getField(0)->getType()); - $this->assertSame(self::GPBTYPE_ENUM, $mapDesc->getField(1)->getType()); - } - - /** - * @expectedException \Exception - */ - public function testFieldDescriptorEnumException() - { - $pool = DescriptorPool::getGeneratedPool(); - $desc = $pool->getDescriptorByClassName(get_class(new TestDescriptorsMessage())); - $fieldDesc = $desc->getField(0); - $fieldDesc->getEnumType(); - } - - /** - * @expectedException \Exception - */ - public function testFieldDescriptorMessageException() - { - $pool = DescriptorPool::getGeneratedPool(); - $desc = $pool->getDescriptorByClassName(get_class(new TestDescriptorsMessage())); - $fieldDesc = $desc->getField(0); - $fieldDesc->getMessageType(); - } - - ######################################################### - # Test oneof descriptor. - ######################################################### - - public function testOneofDescriptor() - { - $pool = DescriptorPool::getGeneratedPool(); - $desc = $pool->getDescriptorByClassName(get_class(new TestDescriptorsMessage())); - - $fieldDescMap = $this->buildFieldMap($desc); - $fieldDesc = $fieldDescMap[51]; - - $oneofDesc = $desc->getOneofDecl(0); - - $this->assertSame('my_oneof', $oneofDesc->getName()); - $fieldDescFromOneof = $oneofDesc->getField(0); - $this->assertSame($fieldDesc, $fieldDescFromOneof); - $this->assertSame(1, $oneofDesc->getFieldCount()); - } - - private function buildFieldMap($desc) - { - $fieldDescMap = []; - for ($i = 0; $i < $desc->getFieldCount(); $i++) { - $fieldDesc = $desc->getField($i); - $fieldDescMap[$fieldDesc->getNumber()] = $fieldDesc; - } - return $fieldDescMap; - } -} diff --git a/third_party/protobuf/3.4.0/php/tests/encode_decode_test.php b/third_party/protobuf/3.4.0/php/tests/encode_decode_test.php deleted file mode 100644 index b43dffb4fe..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/encode_decode_test.php +++ /dev/null @@ -1,453 +0,0 @@ -<?php - -require_once('test_base.php'); -require_once('test_util.php'); - -use Google\Protobuf\RepeatedField; -use Google\Protobuf\GPBType; -use Foo\TestEnum; -use Foo\TestMessage; -use Foo\TestMessage_Sub; -use Foo\TestPackedMessage; -use Foo\TestRandomFieldOrder; -use Foo\TestUnpackedMessage; - -class EncodeDecodeTest extends TestBase -{ - - public function testEncode() - { - $from = new TestMessage(); - $this->expectEmptyFields($from); - $this->setFields($from); - $this->expectFields($from); - - $data = $from->serializeToString(); - $this->assertSame(bin2hex(TestUtil::getGoldenTestMessage()), - bin2hex($data)); - } - - public function testDecode() - { - $to = new TestMessage(); - $to->mergeFromString(TestUtil::getGoldenTestMessage()); - $this->expectFields($to); - } - - public function testEncodeDecode() - { - $from = new TestMessage(); - $this->expectEmptyFields($from); - $this->setFields($from); - $this->expectFields($from); - - $data = $from->serializeToString(); - - $to = new TestMessage(); - $to->mergeFromString($data); - $this->expectFields($to); - } - - public function testEncodeDecodeEmpty() - { - $from = new TestMessage(); - $this->expectEmptyFields($from); - - $data = $from->serializeToString(); - - $to = new TestMessage(); - $to->mergeFromString($data); - $this->expectEmptyFields($to); - } - - public function testEncodeDecodeOneof() - { - $m = new TestMessage(); - - $m->setOneofInt32(1); - $data = $m->serializeToString(); - $n = new TestMessage(); - $n->mergeFromString($data); - $this->assertSame(1, $n->getOneofInt32()); - - $m->setOneofFloat(2.0); - $data = $m->serializeToString(); - $n = new TestMessage(); - $n->mergeFromString($data); - $this->assertSame(2.0, $n->getOneofFloat()); - - $m->setOneofString('abc'); - $data = $m->serializeToString(); - $n = new TestMessage(); - $n->mergeFromString($data); - $this->assertSame('abc', $n->getOneofString()); - - $sub_m = new TestMessage_Sub(); - $sub_m->setA(1); - $m->setOneofMessage($sub_m); - $data = $m->serializeToString(); - $n = new TestMessage(); - $n->mergeFromString($data); - $this->assertSame(1, $n->getOneofMessage()->getA()); - - // Encode default value - $m->setOneofEnum(TestEnum::ZERO); - $data = $m->serializeToString(); - $n = new TestMessage(); - $n->mergeFromString($data); - $this->assertSame("oneof_enum", $n->getMyOneof()); - $this->assertSame(TestEnum::ZERO, $n->getOneofEnum()); - - $m->setOneofString(""); - $data = $m->serializeToString(); - $n = new TestMessage(); - $n->mergeFromString($data); - $this->assertSame("oneof_string", $n->getMyOneof()); - $this->assertSame("", $n->getOneofString()); - - $sub_m = new TestMessage_Sub(); - $m->setOneofMessage($sub_m); - $data = $m->serializeToString(); - $n = new TestMessage(); - $n->mergeFromString($data); - $this->assertSame("oneof_message", $n->getMyOneof()); - $this->assertFalse(is_null($n->getOneofMessage())); - - } - - public function testPackedEncode() - { - $from = new TestPackedMessage(); - TestUtil::setTestPackedMessage($from); - $this->assertSame(TestUtil::getGoldenTestPackedMessage(), - $from->serializeToString()); - } - - public function testPackedDecodePacked() - { - $to = new TestPackedMessage(); - $to->mergeFromString(TestUtil::getGoldenTestPackedMessage()); - TestUtil::assertTestPackedMessage($to); - } - - public function testPackedDecodeUnpacked() - { - $to = new TestPackedMessage(); - $to->mergeFromString(TestUtil::getGoldenTestUnpackedMessage()); - TestUtil::assertTestPackedMessage($to); - } - - public function testUnpackedEncode() - { - $from = new TestUnpackedMessage(); - TestUtil::setTestPackedMessage($from); - $this->assertSame(TestUtil::getGoldenTestUnpackedMessage(), - $from->serializeToString()); - } - - public function testUnpackedDecodePacked() - { - $to = new TestUnpackedMessage(); - $to->mergeFromString(TestUtil::getGoldenTestPackedMessage()); - TestUtil::assertTestPackedMessage($to); - } - - public function testUnpackedDecodeUnpacked() - { - $to = new TestUnpackedMessage(); - $to->mergeFromString(TestUtil::getGoldenTestUnpackedMessage()); - TestUtil::assertTestPackedMessage($to); - } - - public function testDecodeInt64() - { - // Read 64 testing - $testVals = array( - '10' => '100a', - '100' => '1064', - '800' => '10a006', - '6400' => '108032', - '70400' => '1080a604', - '774400' => '1080a22f', - '9292800' => '108098b704', - '74342400' => '1080c0b923', - '743424000' => '108080bfe202', - '8177664000' => '108080b5bb1e', - '65421312000' => '108080a8dbf301', - '785055744000' => '108080e0c7ec16', - '9420668928000' => '10808080dd969202', - '103627358208000' => '10808080fff9c717', - '1139900940288000' => '10808080f5bd978302', - '13678811283456000' => '10808080fce699a618', - '109430490267648000' => '10808080e0b7ceb1c201', - '984874412408832000' => '10808080e0f5c1bed50d', - ); - - $msg = new TestMessage(); - foreach ($testVals as $original => $encoded) { - $msg->setOptionalInt64($original); - $data = $msg->serializeToString(); - $this->assertSame($encoded, bin2hex($data)); - $msg->setOptionalInt64(0); - $msg->mergeFromString($data); - $this->assertEquals($original, $msg->getOptionalInt64()); - } - } - - public function testDecodeToExistingMessage() - { - $m1 = new TestMessage(); - $this->setFields($m1); - $this->expectFields($m1); - - $m2 = new TestMessage(); - $this->setFields2($m2); - $data = $m2->serializeToString(); - - $m1->mergeFromString($data); - $this->expectFieldsMerged($m1); - } - - public function testDecodeFieldNonExist() - { - $data = hex2bin('c80501'); - $m = new TestMessage(); - $m->mergeFromString($data); - } - - public function testEncodeNegativeInt32() - { - $m = new TestMessage(); - $m->setOptionalInt32(-1); - $data = $m->serializeToString(); - $this->assertSame("08ffffffffffffffffff01", bin2hex($data)); - } - - public function testDecodeNegativeInt32() - { - $m = new TestMessage(); - $this->assertEquals(0, $m->getOptionalInt32()); - $m->mergeFromString(hex2bin("08ffffffffffffffffff01")); - $this->assertEquals(-1, $m->getOptionalInt32()); - - $m = new TestMessage(); - $this->assertEquals(0, $m->getOptionalInt32()); - $m->mergeFromString(hex2bin("08ffffffff0f")); - $this->assertEquals(-1, $m->getOptionalInt32()); - } - - public function testRandomFieldOrder() - { - $m = new TestRandomFieldOrder(); - $data = $m->serializeToString(); - $this->assertSame("", $data); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidInt32() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('08')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidSubMessage() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('9A010108')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidInt64() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('10')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidUInt32() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('18')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidUInt64() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('20')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidSInt32() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('28')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidSInt64() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('30')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidFixed32() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('3D')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidFixed64() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('41')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidSFixed32() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('4D')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidSFixed64() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('51')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidFloat() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('5D')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidDouble() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('61')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidBool() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('68')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidStringLengthMiss() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('72')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidStringDataMiss() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('7201')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidBytesLengthMiss() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('7A')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidBytesDataMiss() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('7A01')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidEnum() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('8001')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidMessageLengthMiss() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('8A01')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidMessageDataMiss() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('8A0101')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidPackedMessageLength() - { - $m = new TestPackedMessage(); - $m->mergeFromString(hex2bin('D205')); - } - - public function testJsonEncode() - { - $from = new TestMessage(); - $this->setFields($from); - $data = $from->serializeToJsonString(); - $to = new TestMessage(); - $to->mergeFromJsonString($data); - $this->expectFields($to); - } -} diff --git a/third_party/protobuf/3.4.0/php/tests/gdb_test.sh b/third_party/protobuf/3.4.0/php/tests/gdb_test.sh deleted file mode 100755 index 484e2edfbb..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/gdb_test.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so `which -# phpunit` --bootstrap autoload.php tmp_test.php -# -gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so `which phpunit` --bootstrap autoload.php encode_decode_test.php -# -# gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php -# -# USE_ZEND_ALLOC=0 valgrind --leak-check=yes php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php diff --git a/third_party/protobuf/3.4.0/php/tests/generated_class_test.php b/third_party/protobuf/3.4.0/php/tests/generated_class_test.php deleted file mode 100644 index 86e68683c0..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/generated_class_test.php +++ /dev/null @@ -1,718 +0,0 @@ -<?php - -require_once('generated/NoNamespaceEnum.php'); -require_once('generated/NoNamespaceMessage.php'); -require_once('test_base.php'); -require_once('test_util.php'); - -use Google\Protobuf\Internal\RepeatedField; -use Google\Protobuf\Internal\MapField; -use Google\Protobuf\Internal\GPBType; -use Foo\TestEnum; -use Foo\TestIncludeNamespaceMessage; -use Foo\TestIncludePrefixMessage; -use Foo\TestMessage; -use Foo\TestMessage_Sub; -use Foo\TestReverseFieldOrder; -use Php\Test\TestNamespace; - -class GeneratedClassTest extends TestBase -{ - - ######################################################### - # Test field accessors. - ######################################################### - - public function testSetterGetter() - { - $m = new TestMessage(); - $m->setOptionalInt32(1); - $this->assertSame(1, $m->getOptionalInt32()); - } - - ######################################################### - # Test int32 field. - ######################################################### - - public function testInt32Field() - { - $m = new TestMessage(); - - // Set integer. - $m->setOptionalInt32(MAX_INT32); - $this->assertSame(MAX_INT32, $m->getOptionalInt32()); - $m->setOptionalInt32(MIN_INT32); - $this->assertSame(MIN_INT32, $m->getOptionalInt32()); - - // Set float. - $m->setOptionalInt32(1.1); - $this->assertSame(1, $m->getOptionalInt32()); - $m->setOptionalInt32(MAX_INT32_FLOAT); - $this->assertSame(MAX_INT32, $m->getOptionalInt32()); - $m->setOptionalInt32(MIN_INT32_FLOAT); - $this->assertSame(MIN_INT32, $m->getOptionalInt32()); - - // Set string. - $m->setOptionalInt32('2'); - $this->assertSame(2, $m->getOptionalInt32()); - $m->setOptionalInt32('3.1'); - $this->assertSame(3, $m->getOptionalInt32()); - $m->setOptionalInt32(MAX_INT32_STRING); - $this->assertSame(MAX_INT32, $m->getOptionalInt32()); - $m->setOptionalInt32(MIN_INT32_STRING); - $this->assertSame(MIN_INT32, $m->getOptionalInt32()); - } - - ######################################################### - # Test uint32 field. - ######################################################### - - public function testUint32Field() - { - $m = new TestMessage(); - - // Set integer. - $m->setOptionalUint32(MAX_UINT32); - $this->assertSame(-1, $m->getOptionalUint32()); - $m->setOptionalUint32(-1); - $this->assertSame(-1, $m->getOptionalUint32()); - $m->setOptionalUint32(MIN_UINT32); - $this->assertSame(MIN_INT32, $m->getOptionalUint32()); - - // Set float. - $m->setOptionalUint32(1.1); - $this->assertSame(1, $m->getOptionalUint32()); - $m->setOptionalUint32(MAX_UINT32_FLOAT); - $this->assertSame(-1, $m->getOptionalUint32()); - $m->setOptionalUint32(-1.0); - $this->assertSame(-1, $m->getOptionalUint32()); - $m->setOptionalUint32(MIN_UINT32_FLOAT); - $this->assertSame(MIN_INT32, $m->getOptionalUint32()); - - // Set string. - $m->setOptionalUint32('2'); - $this->assertSame(2, $m->getOptionalUint32()); - $m->setOptionalUint32('3.1'); - $this->assertSame(3, $m->getOptionalUint32()); - $m->setOptionalUint32(MAX_UINT32_STRING); - $this->assertSame(-1, $m->getOptionalUint32()); - $m->setOptionalUint32('-1.0'); - $this->assertSame(-1, $m->getOptionalUint32()); - $m->setOptionalUint32(MIN_UINT32_STRING); - $this->assertSame(MIN_INT32, $m->getOptionalUint32()); - } - - ######################################################### - # Test int64 field. - ######################################################### - - public function testInt64Field() - { - $m = new TestMessage(); - - // Set integer. - $m->setOptionalInt64(MAX_INT64); - $this->assertSame(MAX_INT64, $m->getOptionalInt64()); - $m->setOptionalInt64(MIN_INT64); - $this->assertEquals(MIN_INT64, $m->getOptionalInt64()); - - // Set float. - $m->setOptionalInt64(1.1); - if (PHP_INT_SIZE == 4) { - $this->assertSame('1', $m->getOptionalInt64()); - } else { - $this->assertSame(1, $m->getOptionalInt64()); - } - - // Set string. - $m->setOptionalInt64('2'); - if (PHP_INT_SIZE == 4) { - $this->assertSame('2', $m->getOptionalInt64()); - } else { - $this->assertSame(2, $m->getOptionalInt64()); - } - - $m->setOptionalInt64('3.1'); - if (PHP_INT_SIZE == 4) { - $this->assertSame('3', $m->getOptionalInt64()); - } else { - $this->assertSame(3, $m->getOptionalInt64()); - } - - $m->setOptionalInt64(MAX_INT64_STRING); - if (PHP_INT_SIZE == 4) { - $this->assertSame(MAX_INT64_STRING, $m->getOptionalInt64()); - } else { - $this->assertSame(MAX_INT64, $m->getOptionalInt64()); - } - - $m->setOptionalInt64(MIN_INT64_STRING); - if (PHP_INT_SIZE == 4) { - $this->assertSame(MIN_INT64_STRING, $m->getOptionalInt64()); - } else { - $this->assertSame(MIN_INT64, $m->getOptionalInt64()); - } - } - - ######################################################### - # Test uint64 field. - ######################################################### - - public function testUint64Field() - { - $m = new TestMessage(); - - // Set integer. - $m->setOptionalUint64(MAX_UINT64); - if (PHP_INT_SIZE == 4) { - $this->assertSame(MAX_UINT64_STRING, $m->getOptionalUint64()); - } else { - $this->assertSame(MAX_UINT64, $m->getOptionalUint64()); - } - - // Set float. - $m->setOptionalUint64(1.1); - if (PHP_INT_SIZE == 4) { - $this->assertSame('1', $m->getOptionalUint64()); - } else { - $this->assertSame(1, $m->getOptionalUint64()); - } - - // Set string. - $m->setOptionalUint64('2'); - if (PHP_INT_SIZE == 4) { - $this->assertSame('2', $m->getOptionalUint64()); - } else { - $this->assertSame(2, $m->getOptionalUint64()); - } - - $m->setOptionalUint64('3.1'); - if (PHP_INT_SIZE == 4) { - $this->assertSame('3', $m->getOptionalUint64()); - } else { - $this->assertSame(3, $m->getOptionalUint64()); - } - - $m->setOptionalUint64(MAX_UINT64_STRING); - if (PHP_INT_SIZE == 4) { - $this->assertSame(MAX_UINT64_STRING, $m->getOptionalUint64()); - } else { - $this->assertSame(MAX_UINT64, $m->getOptionalUint64()); - } - } - - ######################################################### - # Test enum field. - ######################################################### - - public function testEnumField() - { - $m = new TestMessage(); - - // Set enum. - $m->setOptionalEnum(TestEnum::ONE); - $this->assertEquals(TestEnum::ONE, $m->getOptionalEnum()); - - // Set integer. - $m->setOptionalEnum(1); - $this->assertEquals(TestEnum::ONE, $m->getOptionalEnum()); - - // Set float. - $m->setOptionalEnum(1.1); - $this->assertEquals(TestEnum::ONE, $m->getOptionalEnum()); - - // Set string. - $m->setOptionalEnum("1"); - $this->assertEquals(TestEnum::ONE, $m->getOptionalEnum()); - } - - public function testNestedEnum() - { - $m = new TestMessage(); - $m->setOptionalNestedEnum(\Foo\TestMessage_NestedEnum::ZERO); - } - - ######################################################### - # Test float field. - ######################################################### - - public function testFloatField() - { - $m = new TestMessage(); - - // Set integer. - $m->setOptionalFloat(1); - $this->assertEquals(1.0, $m->getOptionalFloat(), '', MAX_FLOAT_DIFF); - - // Set float. - $m->setOptionalFloat(1.1); - $this->assertEquals(1.1, $m->getOptionalFloat(), '', MAX_FLOAT_DIFF); - - // Set string. - $m->setOptionalFloat('2'); - $this->assertEquals(2.0, $m->getOptionalFloat(), '', MAX_FLOAT_DIFF); - $m->setOptionalFloat('3.1'); - $this->assertEquals(3.1, $m->getOptionalFloat(), '', MAX_FLOAT_DIFF); - } - - ######################################################### - # Test double field. - ######################################################### - - public function testDoubleField() - { - $m = new TestMessage(); - - // Set integer. - $m->setOptionalDouble(1); - $this->assertEquals(1.0, $m->getOptionalDouble(), '', MAX_FLOAT_DIFF); - - // Set float. - $m->setOptionalDouble(1.1); - $this->assertEquals(1.1, $m->getOptionalDouble(), '', MAX_FLOAT_DIFF); - - // Set string. - $m->setOptionalDouble('2'); - $this->assertEquals(2.0, $m->getOptionalDouble(), '', MAX_FLOAT_DIFF); - $m->setOptionalDouble('3.1'); - $this->assertEquals(3.1, $m->getOptionalDouble(), '', MAX_FLOAT_DIFF); - } - - ######################################################### - # Test bool field. - ######################################################### - - public function testBoolField() - { - $m = new TestMessage(); - - // Set bool. - $m->setOptionalBool(true); - $this->assertSame(true, $m->getOptionalBool()); - - // Set integer. - $m->setOptionalBool(-1); - $this->assertSame(true, $m->getOptionalBool()); - - // Set float. - $m->setOptionalBool(1.1); - $this->assertSame(true, $m->getOptionalBool()); - - // Set string. - $m->setOptionalBool(''); - $this->assertSame(false, $m->getOptionalBool()); - } - - ######################################################### - # Test string field. - ######################################################### - - public function testStringField() - { - $m = new TestMessage(); - - // Set string. - $m->setOptionalString('abc'); - $this->assertSame('abc', $m->getOptionalString()); - - // Set integer. - $m->setOptionalString(1); - $this->assertSame('1', $m->getOptionalString()); - - // Set double. - $m->setOptionalString(1.1); - $this->assertSame('1.1', $m->getOptionalString()); - - // Set bool. - $m->setOptionalString(true); - $this->assertSame('1', $m->getOptionalString()); - } - - ######################################################### - # Test bytes field. - ######################################################### - - public function testBytesField() - { - $m = new TestMessage(); - - // Set string. - $m->setOptionalBytes('abc'); - $this->assertSame('abc', $m->getOptionalBytes()); - - // Set integer. - $m->setOptionalBytes(1); - $this->assertSame('1', $m->getOptionalBytes()); - - // Set double. - $m->setOptionalBytes(1.1); - $this->assertSame('1.1', $m->getOptionalBytes()); - - // Set bool. - $m->setOptionalBytes(true); - $this->assertSame('1', $m->getOptionalBytes()); - } - - public function testBytesFieldInvalidUTF8Success() - { - $m = new TestMessage(); - $hex = hex2bin("ff"); - $m->setOptionalBytes($hex); - } - - ######################################################### - # Test message field. - ######################################################### - - public function testMessageField() - { - $m = new TestMessage(); - - $sub_m = new TestMessage_Sub(); - $sub_m->setA(1); - $m->setOptionalMessage($sub_m); - $this->assertSame(1, $m->getOptionalMessage()->getA()); - - $null = null; - $m->setOptionalMessage($null); - $this->assertNull($m->getOptionalMessage()); - } - - ######################################################### - # Test repeated field. - ######################################################### - - public function testRepeatedField() - { - $m = new TestMessage(); - - $repeated_int32 = new RepeatedField(GPBType::INT32); - $m->setRepeatedInt32($repeated_int32); - $this->assertSame($repeated_int32, $m->getRepeatedInt32()); - } - - public function testRepeatedFieldViaArray() - { - $m = new TestMessage(); - - $arr = array(); - $m->setRepeatedInt32($arr); - $this->assertSame(0, count($m->getRepeatedInt32())); - - $arr = array(1, 2.1, "3"); - $m->setRepeatedInt32($arr); - $this->assertTrue($m->getRepeatedInt32() instanceof RepeatedField); - $this->assertSame("Google\Protobuf\Internal\RepeatedField", - get_class($m->getRepeatedInt32())); - $this->assertSame(3, count($m->getRepeatedInt32())); - $this->assertSame(1, $m->getRepeatedInt32()[0]); - $this->assertSame(2, $m->getRepeatedInt32()[1]); - $this->assertSame(3, $m->getRepeatedInt32()[2]); - $this->assertFalse($arr instanceof RepeatedField); - } - - ######################################################### - # Test map field. - ######################################################### - - public function testMapField() - { - $m = new TestMessage(); - - $map_int32_int32 = new MapField(GPBType::INT32, GPBType::INT32); - $m->setMapInt32Int32($map_int32_int32); - $this->assertSame($map_int32_int32, $m->getMapInt32Int32()); - } - - public function testMapFieldViaArray() - { - $m = new TestMessage(); - - $dict = array(); - $m->setMapInt32Int32($dict); - $this->assertSame(0, count($m->getMapInt32Int32())); - - $dict = array(5 => 5, 6.1 => 6.1, "7" => "7"); - $m->setMapInt32Int32($dict); - $this->assertTrue($m->getMapInt32Int32() instanceof MapField); - $this->assertSame(3, count($m->getMapInt32Int32())); - $this->assertSame(5, $m->getMapInt32Int32()[5]); - $this->assertSame(6, $m->getMapInt32Int32()[6]); - $this->assertSame(7, $m->getMapInt32Int32()[7]); - $this->assertFalse($dict instanceof MapField); - } - - ######################################################### - # Test oneof field. - ######################################################### - - public function testOneofField() { - $m = new TestMessage(); - - $this->assertSame("", $m->getMyOneof()); - - $m->setOneofInt32(1); - $this->assertSame(1, $m->getOneofInt32()); - $this->assertSame(0.0, $m->getOneofFloat()); - $this->assertSame('', $m->getOneofString()); - $this->assertSame(NULL, $m->getOneofMessage()); - $this->assertSame("oneof_int32", $m->getMyOneof()); - - $m->setOneofFloat(2.0); - $this->assertSame(0, $m->getOneofInt32()); - $this->assertSame(2.0, $m->getOneofFloat()); - $this->assertSame('', $m->getOneofString()); - $this->assertSame(NULL, $m->getOneofMessage()); - $this->assertSame("oneof_float", $m->getMyOneof()); - - $m->setOneofString('abc'); - $this->assertSame(0, $m->getOneofInt32()); - $this->assertSame(0.0, $m->getOneofFloat()); - $this->assertSame('abc', $m->getOneofString()); - $this->assertSame(NULL, $m->getOneofMessage()); - $this->assertSame("oneof_string", $m->getMyOneof()); - - $sub_m = new TestMessage_Sub(); - $sub_m->setA(1); - $m->setOneofMessage($sub_m); - $this->assertSame(0, $m->getOneofInt32()); - $this->assertSame(0.0, $m->getOneofFloat()); - $this->assertSame('', $m->getOneofString()); - $this->assertSame(1, $m->getOneofMessage()->getA()); - $this->assertSame("oneof_message", $m->getMyOneof()); - } - - ######################################################### - # Test clear method. - ######################################################### - - public function testMessageClear() - { - $m = new TestMessage(); - $this->setFields($m); - $this->expectFields($m); - $m->clear(); - $this->expectEmptyFields($m); - } - - ######################################################### - # Test mergeFrom method. - ######################################################### - - public function testMessageMergeFrom() - { - $m = new TestMessage(); - $this->setFields($m); - $this->expectFields($m); - $arr = $m->getOptionalMessage()->getB(); - $arr[] = 1; - - $n = new TestMessage(); - - // Singular - $n->setOptionalInt32(100); - $sub1 = new TestMessage_Sub(); - $sub1->setA(101); - - $b = $sub1->getB(); - $b[] = 102; - $sub1->setB($b); - - $n->setOptionalMessage($sub1); - - // Repeated - $repeatedInt32 = $n->getRepeatedInt32(); - $repeatedInt32[] = 200; - $n->setRepeatedInt32($repeatedInt32); - - $repeatedString = $n->getRepeatedString(); - $repeatedString[] = 'abc'; - $n->setRepeatedString($repeatedString); - - $sub2 = new TestMessage_Sub(); - $sub2->setA(201); - $repeatedMessage = $n->getRepeatedMessage(); - $repeatedMessage[] = $sub2; - $n->setRepeatedMessage($repeatedMessage); - - // Map - $mapInt32Int32 = $n->getMapInt32Int32(); - $mapInt32Int32[1] = 300; - $mapInt32Int32[-62] = 301; - $n->setMapInt32Int32($mapInt32Int32); - - $mapStringString = $n->getMapStringString(); - $mapStringString['def'] = 'def'; - $n->setMapStringString($mapStringString); - - $mapInt32Message = $n->getMapInt32Message(); - $mapInt32Message[1] = new TestMessage_Sub(); - $mapInt32Message[1]->setA(302); - $mapInt32Message[2] = new TestMessage_Sub(); - $mapInt32Message[2]->setA(303); - $n->setMapInt32Message($mapInt32Message); - - $m->mergeFrom($n); - - $this->assertSame(100, $m->getOptionalInt32()); - $this->assertSame(42, $m->getOptionalUint32()); - $this->assertSame(101, $m->getOptionalMessage()->getA()); - $this->assertSame(2, count($m->getOptionalMessage()->getB())); - $this->assertSame(1, $m->getOptionalMessage()->getB()[0]); - $this->assertSame(102, $m->getOptionalMessage()->getB()[1]); - - $this->assertSame(3, count($m->getRepeatedInt32())); - $this->assertSame(200, $m->getRepeatedInt32()[2]); - $this->assertSame(2, count($m->getRepeatedUint32())); - $this->assertSame(3, count($m->getRepeatedString())); - $this->assertSame('abc', $m->getRepeatedString()[2]); - $this->assertSame(3, count($m->getRepeatedMessage())); - $this->assertSame(201, $m->getRepeatedMessage()[2]->getA()); - - $this->assertSame(2, count($m->getMapInt32Int32())); - $this->assertSame(300, $m->getMapInt32Int32()[1]); - $this->assertSame(301, $m->getMapInt32Int32()[-62]); - $this->assertSame(1, count($m->getMapUint32Uint32())); - $this->assertSame(2, count($m->getMapStringString())); - $this->assertSame('def', $m->getMapStringString()['def']); - - $this->assertSame(2, count($m->getMapInt32Message())); - $this->assertSame(302, $m->getMapInt32Message()[1]->getA()); - $this->assertSame(303, $m->getMapInt32Message()[2]->getA()); - - $this->assertSame("", $m->getMyOneof()); - - // Check sub-messages are copied by value. - $n->getOptionalMessage()->setA(-101); - $this->assertSame(101, $m->getOptionalMessage()->getA()); - - $repeatedMessage = $n->getRepeatedMessage(); - $repeatedMessage[0]->setA(-201); - $n->setRepeatedMessage($repeatedMessage); - $this->assertSame(201, $m->getRepeatedMessage()[2]->getA()); - - $mapInt32Message = $n->getMapInt32Message(); - $mapInt32Message[1]->setA(-302); - $n->setMapInt32Message($mapInt32Message); - - $this->assertSame(302, $m->getMapInt32Message()[1]->getA()); - - // Test merge oneof. - $m = new TestMessage(); - - $n = new TestMessage(); - $n->setOneofInt32(1); - $m->mergeFrom($n); - $this->assertSame(1, $m->getOneofInt32()); - - $sub = new TestMessage_Sub(); - $n->setOneofMessage($sub); - $n->getOneofMessage()->setA(400); - $m->mergeFrom($n); - $this->assertSame(400, $m->getOneofMessage()->getA()); - $n->getOneofMessage()->setA(-400); - $this->assertSame(400, $m->getOneofMessage()->getA()); - - // Test all fields - $m = new TestMessage(); - $n = new TestMessage(); - $this->setFields($m); - $n->mergeFrom($m); - $this->expectFields($n); - } - - ######################################################### - # Test message/enum without namespace. - ######################################################### - - public function testMessageWithoutNamespace() - { - $m = new TestMessage(); - $sub = new NoNameSpaceMessage(); - $m->setOptionalNoNamespaceMessage($sub); - $repeatedNoNamespaceMessage = $m->getRepeatedNoNamespaceMessage(); - $repeatedNoNamespaceMessage[] = new NoNameSpaceMessage(); - $m->setRepeatedNoNamespaceMessage($repeatedNoNamespaceMessage); - - $n = new NoNamespaceMessage(); - $n->setB(NoNamespaceMessage_NestedEnum::ZERO); - } - - public function testEnumWithoutNamespace() - { - $m = new TestMessage(); - $m->setOptionalNoNamespaceEnum(NoNameSpaceEnum::VALUE_A); - $repeatedNoNamespaceEnum = $m->getRepeatedNoNamespaceEnum(); - $repeatedNoNamespaceEnum[] = NoNameSpaceEnum::VALUE_A; - $m->setRepeatedNoNamespaceEnum($repeatedNoNamespaceEnum); - } - - ######################################################### - # Test message with given prefix. - ######################################################### - - public function testPrefixMessage() - { - $m = new TestIncludePrefixMessage(); - $n = new PrefixTestPrefix(); - $n->setA(1); - $m->setPrefixMessage($n); - $this->assertSame(1, $m->getPrefixMessage()->getA()); - } - - ######################################################### - # Test message with given namespace. - ######################################################### - - public function testNamespaceMessage() - { - $m = new TestIncludeNamespaceMessage(); - - $n = new TestNamespace(); - $n->setA(1); - $m->setNamespaceMessage($n); - $this->assertSame(1, $m->getNamespaceMessage()->getA()); - - $n = new TestEmptyNamespace(); - $n->setA(1); - $m->setEmptyNamespaceMessage($n); - $this->assertSame(1, $m->getEmptyNamespaceMessage()->getA()); - } - - ######################################################### - # Test prefix for reserved words. - ######################################################### - - public function testPrefixForReservedWords() - { - $m = new \Foo\TestMessage_Empty(); - $m = new \Foo\PBEmpty(); - $m = new \PrefixEmpty(); - $m = new \Foo\PBARRAY(); - } - - ######################################################### - # Test fluent setters. - ######################################################### - - public function testFluentSetters() - { - $m = (new TestMessage()) - ->setOptionalInt32(1) - ->setOptionalUInt32(2); - $this->assertSame(1, $m->getOptionalInt32()); - $this->assertSame(2, $m->getOptionalUInt32()); - } - - ######################################################### - # Test Reverse Field Order. - ######################################################### - - public function testReverseFieldOrder() - { - $m = new TestReverseFieldOrder(); - $m->setB("abc"); - $this->assertSame("abc", $m->getB()); - $this->assertNotSame("abc", $m->getA()); - } -} diff --git a/third_party/protobuf/3.4.0/php/tests/generated_phpdoc_test.php b/third_party/protobuf/3.4.0/php/tests/generated_phpdoc_test.php deleted file mode 100644 index 6c1a26f7a2..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/generated_phpdoc_test.php +++ /dev/null @@ -1,337 +0,0 @@ -<?php - -require_once('generated/NoNamespaceEnum.php'); -require_once('generated/NoNamespaceMessage.php'); -require_once('test_base.php'); -require_once('test_util.php'); - -use Foo\TestMessage; - -class GeneratedPhpdocTest extends TestBase -{ - public function testPhpDocForClass() - { - $class = new ReflectionClass('Foo\TestMessage'); - $doc = $class->getDocComment(); - $this->assertContains('foo.TestMessage', $doc); - } - - /** - * @dataProvider providePhpDocForGettersAndSetters - */ - public function testPhpDocForIntGetters($methods, $expectedDoc) - { - $class = new ReflectionClass('Foo\TestMessage'); - foreach ($methods as $method) { - $doc = $class->getMethod($method)->getDocComment(); - $this->assertContains($expectedDoc, $doc); - } - } - - public function providePhpDocForGettersAndSetters() - { - return [ - [ - [ - 'setOptionalInt32', - 'setOptionalUint32', - 'setOptionalSint32', - 'setOptionalFixed32', - 'setOptionalSfixed32', - 'setOneofInt32', - 'setOneofUint32', - 'setOneofSint32', - 'setOneofFixed32', - 'setOneofSfixed32', - 'setOptionalEnum', - 'setOptionalNoNamespaceEnum', - 'setOptionalNestedEnum', - 'setOneofEnum' - ], - '@param int $var' - ], - [ - [ - 'setOptionalInt64', - 'setOptionalUint64', - 'setOptionalSint64', - 'setOptionalFixed64', - 'setOptionalSfixed64', - 'setOneofInt64', - 'setOneofUint64', - 'setOneofSint64', - 'setOneofFixed64', - 'setOneofSfixed64', - ], - '@param int|string $var' - ], - [ - [ - 'getOptionalInt32', - 'getOptionalUint32', - 'getOptionalSint32', - 'getOptionalFixed32', - 'getOptionalSfixed32', - 'getOneofInt32', - 'getOneofUint32', - 'getOneofSint32', - 'getOneofFixed32', - 'getOneofSfixed32', - 'getOptionalEnum', - 'getOptionalNoNamespaceEnum', - 'getOptionalNestedEnum', - 'getOneofEnum', - ], - '@return int' - ], - [ - [ - 'setOptionalInt64', - 'setOptionalUint64', - 'setOptionalSint64', - 'setOptionalFixed64', - 'setOptionalSfixed64', - 'setOneofInt64', - 'setOneofUint64', - 'setOneofSint64', - 'setOneofFixed64', - 'setOneofSfixed64', - ], - '@param int|string $var' - ], - [ - [ - 'getRepeatedInt32', - 'getRepeatedInt64', - 'getRepeatedUint32', - 'getRepeatedUint64', - 'getRepeatedSint32', - 'getRepeatedSint64', - 'getRepeatedFixed32', - 'getRepeatedFixed64', - 'getRepeatedSfixed32', - 'getRepeatedSfixed64', - 'getRepeatedFloat', - 'getRepeatedDouble', - 'getRepeatedBool', - 'getRepeatedString', - 'getRepeatedBytes', - 'getRepeatedEnum', - 'getRepeatedMessage', - 'getRepeatedRecursive', - 'getRepeatedNoNamespaceMessage', - 'getRepeatedNoNamespaceEnum', - ], - '@return \Google\Protobuf\Internal\RepeatedField' - ], - [ - [ - 'getMapInt32Int32', - 'getMapInt64Int64', - 'getMapUint32Uint32', - 'getMapUint64Uint64', - 'getMapSint32Sint32', - 'getMapSint64Sint64', - 'getMapFixed32Fixed32', - 'getMapFixed64Fixed64', - 'getMapSfixed32Sfixed32', - 'getMapSfixed64Sfixed64', - 'getMapInt32Float', - 'getMapInt32Double', - 'getMapBoolBool', - 'getMapStringString', - 'getMapInt32Bytes', - 'getMapInt32Enum', - 'getMapInt32Message', - 'getMapRecursive', - ], - '@return \Google\Protobuf\Internal\MapField' - ], - [ - [ - 'setRepeatedInt32', - 'setRepeatedUint32', - 'setRepeatedSint32', - 'setRepeatedFixed32', - 'setRepeatedSfixed32', - 'setRepeatedEnum', - 'setRepeatedNoNamespaceEnum', - ], - '@param int[]|\Google\Protobuf\Internal\RepeatedField $var' - ], - [ - [ - 'setRepeatedInt64', - 'setRepeatedUint64', - 'setRepeatedSint64', - 'setRepeatedFixed64', - 'setRepeatedSfixed64', - ], - '@param int[]|string[]|\Google\Protobuf\Internal\RepeatedField $var' - ], - [ - [ - 'setRepeatedFloat', - 'setRepeatedDouble', - ], - '@param float[]|\Google\Protobuf\Internal\RepeatedField $var' - ], - [ - [ - 'setRepeatedBool', - ], - '@param bool[]|\Google\Protobuf\Internal\RepeatedField $var' - ], - [ - [ - 'setRepeatedString', - 'setRepeatedBytes', - ], - '@param string[]|\Google\Protobuf\Internal\RepeatedField $var' - ], - [ - [ - 'setRepeatedMessage', - ], - '@param \Foo\TestMessage_Sub[]|\Google\Protobuf\Internal\RepeatedField $var' - ], - [ - [ - 'setRepeatedRecursive', - ], - '@param \Foo\TestMessage[]|\Google\Protobuf\Internal\RepeatedField $var' - ], - [ - [ - 'setRepeatedNoNamespaceMessage', - ], - '@param \NoNamespaceMessage[]|\Google\Protobuf\Internal\RepeatedField $var' - ], - [ - [ - 'setMapInt32Int32', - 'setMapInt64Int64', - 'setMapUint32Uint32', - 'setMapUint64Uint64', - 'setMapSint32Sint32', - 'setMapSint64Sint64', - 'setMapFixed32Fixed32', - 'setMapFixed64Fixed64', - 'setMapSfixed32Sfixed32', - 'setMapSfixed64Sfixed64', - 'setMapInt32Float', - 'setMapInt32Double', - 'setMapBoolBool', - 'setMapStringString', - 'setMapInt32Bytes', - 'setMapInt32Enum', - 'setMapInt32Message', - 'setMapRecursive', - ], - '@param array|\Google\Protobuf\Internal\MapField $var' - ], - [ - [ - 'getOptionalFloat', - 'getOptionalDouble', - 'getOneofDouble', - 'getOneofFloat', - ], - '@return float' - ], - [ - [ - 'setOptionalFloat', - 'setOptionalDouble', - 'setOneofDouble', - 'setOneofFloat', - ], - '@param float $var' - ], - [ - [ - 'getOptionalBool', - 'getOneofBool', - ], - '@return bool'], - [ - [ - 'setOptionalBool', - 'setOneofBool', - ], - '@param bool $var' - ], - [ - [ - 'getOptionalString', - 'getOptionalBytes', - 'getOneofString', - 'getOneofBytes', - 'getMyOneof', - ], - '@return string' - ], - [ - [ - 'setOptionalString', - 'setOptionalBytes', - 'setOneofString', - 'setOneofBytes', - ], - '@param string $var' - ], - - [ - [ - 'getOptionalMessage', - 'getOneofMessage' - ], - '@return \Foo\TestMessage_Sub' - ], - [ - [ - 'setOptionalMessage', - 'setOneofMessage' - ], - '@param \Foo\TestMessage_Sub $var' - ], - [ - [ - 'getOptionalIncludedMessage' - ], - '@return \Bar\TestInclude' - ], - [ - [ - 'setOptionalIncludedMessage' - ], - '@param \Bar\TestInclude $var' - ], - [ - [ - 'getRecursive' - ], - '@return \Foo\TestMessage' - ], - [ - [ - 'setRecursive' - ], - '@param \Foo\TestMessage $var' - ], - - [ - [ - 'getOptionalNoNamespaceMessage' - ], - '@return \NoNamespaceMessage' - ], - [ - [ - 'setOptionalNoNamespaceMessage' - ], - '@param \NoNamespaceMessage $var' - ], - ]; - } -} diff --git a/third_party/protobuf/3.4.0/php/tests/generated_service_test.php b/third_party/protobuf/3.4.0/php/tests/generated_service_test.php deleted file mode 100644 index 5407db9a3e..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/generated_service_test.php +++ /dev/null @@ -1,110 +0,0 @@ -<?php - -require_once('test_base.php'); -require_once('test_util.php'); - -use Google\Protobuf\Internal\RepeatedField; -use Google\Protobuf\Internal\MapField; -use Google\Protobuf\Internal\GPBType; -use Foo\Greeter; -use Foo\HelloRequest; -use Foo\HelloReply; - -class GeneratedServiceTest extends TestBase -{ - /** - * @var \ReflectionClass - */ - private $serviceClass; - - /** - * @var \ReflectionClass - */ - private $namespacedServiceClass; - - /** - * @var array - */ - private $methodNames = [ - 'sayHello', - 'sayHelloAgain' - ]; - - public function setUp() - { - parent::setUp(); - - $this->serviceClass = new ReflectionClass('Foo\GreeterInterface'); - - $this->namespacedServiceClass = new ReflectionClass('Bar\OtherGreeterInterface'); - } - - public function testIsInterface() - { - $this->assertTrue($this->serviceClass->isInterface()); - } - - public function testPhpDocForClass() - { - $this->assertContains('foo.Greeter', $this->serviceClass->getDocComment()); - } - - public function testPhpDocForNamespacedClass() - { - $this->assertContains('foo.OtherGreeter', $this->namespacedServiceClass->getDocComment()); - } - - public function testServiceMethodsAreGenerated() - { - $this->assertCount(count($this->methodNames), $this->serviceClass->getMethods()); - foreach ($this->methodNames as $methodName) { - $this->assertTrue($this->serviceClass->hasMethod($methodName)); - } - } - - public function testPhpDocForServiceMethod() - { - foreach ($this->methodNames as $methodName) { - $docComment = $this->serviceClass->getMethod($methodName)->getDocComment(); - $this->assertContains($methodName, $docComment); - $this->assertContains('@param \Foo\HelloRequest $request', $docComment); - $this->assertContains('@return \Foo\HelloReply', $docComment); - } - } - - public function testPhpDocForServiceMethodInNamespacedClass() - { - foreach ($this->methodNames as $methodName) { - $docComment = $this->namespacedServiceClass->getMethod($methodName)->getDocComment(); - $this->assertContains($methodName, $docComment); - $this->assertContains('@param \Foo\HelloRequest $request', $docComment); - $this->assertContains('@return \Foo\HelloReply', $docComment); - } - } - - public function testParamForServiceMethod() - { - foreach ($this->methodNames as $methodName) { - $method = $this->serviceClass->getMethod($methodName); - $this->assertCount(1, $method->getParameters()); - $param = $method->getParameters()[0]; - $this->assertFalse($param->isOptional()); - $this->assertSame('request', $param->getName()); - // ReflectionParameter::getType only exists in PHP 7+, so get the type from __toString - $this->assertContains('Foo\HelloRequest $request', (string) $param); - } - } - - public function testParamForServiceMethodInNamespacedClass() - { - foreach ($this->methodNames as $methodName) { - $method = $this->serviceClass->getMethod($methodName); - $this->assertCount(1, $method->getParameters()); - $param = $method->getParameters()[0]; - $this->assertFalse($param->isOptional()); - $this->assertSame('request', $param->getName()); - // ReflectionParameter::getType only exists in PHP 7+, so get the type from __toString - $this->assertContains('Foo\HelloRequest $request', (string) $param); - } - } -} diff --git a/third_party/protobuf/3.4.0/php/tests/map_field_test.php b/third_party/protobuf/3.4.0/php/tests/map_field_test.php deleted file mode 100644 index cffa2526d0..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/map_field_test.php +++ /dev/null @@ -1,468 +0,0 @@ -<?php - -require_once('test_util.php'); - -use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\MapField; -use Foo\TestMessage; -use Foo\TestMessage_Sub; - -class MapFieldTest extends PHPUnit_Framework_TestCase { - - ######################################################### - # Test int32 field. - ######################################################### - - public function testInt32() { - $arr = new MapField(GPBType::INT32, GPBType::INT32); - - // Test integer argument. - $arr[MAX_INT32] = MAX_INT32; - $this->assertSame(MAX_INT32, $arr[MAX_INT32]); - $arr[MIN_INT32] = MIN_INT32; - $this->assertSame(MIN_INT32, $arr[MIN_INT32]); - $this->assertEquals(2, count($arr)); - $this->assertTrue(isset($arr[MAX_INT32])); - $this->assertTrue(isset($arr[MIN_INT32])); - unset($arr[MAX_INT32]); - unset($arr[MIN_INT32]); - $this->assertEquals(0, count($arr)); - - // Test float argument. - $arr[1.9] = 1.9; - $arr[2.1] = 2.1; - $this->assertSame(1, $arr[1]); - $this->assertSame(2, $arr[2]); - $arr[MAX_INT32_FLOAT] = MAX_INT32_FLOAT; - $this->assertSame(MAX_INT32, $arr[MAX_INT32]); - $arr[MIN_INT32_FLOAT] = MIN_INT32_FLOAT; - $this->assertSame(MIN_INT32, $arr[MIN_INT32]); - $this->assertEquals(4, count($arr)); - unset($arr[1.9]); - unset($arr[2.9]); - unset($arr[MAX_INT32_FLOAT]); - unset($arr[MIN_INT32_FLOAT]); - $this->assertEquals(0, count($arr)); - - // Test string argument. - $arr['2'] = '2'; - $this->assertSame(2, $arr[2]); - $arr['3.1'] = '3.1'; - $this->assertSame(3, $arr[3]); - $arr[MAX_INT32_STRING] = MAX_INT32_STRING; - $this->assertSame(MAX_INT32, $arr[MAX_INT32]); - $this->assertEquals(3, count($arr)); - unset($arr['2']); - unset($arr['3.1']); - unset($arr[MAX_INT32_STRING]); - $this->assertEquals(0, count($arr)); - - // Test foreach. - $arr = new MapField(GPBType::INT32, GPBType::INT32); - for ($i = 0; $i < 3; $i++) { - $arr[$i] = $i; - } - $i = 0; - $arr_test = []; - foreach ($arr as $key => $val) { - $this->assertSame($key, $val); - $arr_test[] = $key; - $i++; - } - $this->assertTrue(isset($arr_test[0])); - $this->assertTrue(isset($arr_test[1])); - $this->assertTrue(isset($arr_test[2])); - $this->assertSame(3, $i); - } - - ######################################################### - # Test uint32 field. - ######################################################### - - public function testUint32() { - $arr = new MapField(GPBType::UINT32, GPBType::UINT32); - - // Test integer argument. - $arr[MAX_UINT32] = MAX_UINT32; - $this->assertSame(-1, $arr[-1]); - $this->assertEquals(1, count($arr)); - unset($arr[MAX_UINT32]); - $this->assertEquals(0, count($arr)); - - $arr[-1] = -1; - $this->assertSame(-1, $arr[-1]); - $arr[MIN_UINT32] = MIN_UINT32; - $this->assertSame(MIN_UINT32, $arr[MIN_UINT32]); - $this->assertEquals(2, count($arr)); - unset($arr[-1]); - unset($arr[MIN_UINT32]); - $this->assertEquals(0, count($arr)); - - // Test float argument. - $arr[MAX_UINT32_FLOAT] = MAX_UINT32_FLOAT; - $this->assertSame(-1, $arr[-1]); - $this->assertEquals(1, count($arr)); - unset($arr[MAX_UINT32_FLOAT]); - $this->assertEquals(0, count($arr)); - - $arr[3.1] = 3.1; - $this->assertSame(3, $arr[3]); - $arr[-1.0] = -1.0; - $this->assertSame(-1, $arr[-1]); - $arr[MIN_UINT32_FLOAT] = MIN_UINT32_FLOAT; - $this->assertSame(MIN_UINT32, $arr[MIN_UINT32]); - $this->assertEquals(3, count($arr)); - unset($arr[3.1]); - unset($arr[-1.0]); - unset($arr[MIN_UINT32_FLOAT]); - $this->assertEquals(0, count($arr)); - - // Test string argument. - $arr[MAX_UINT32_STRING] = MAX_UINT32_STRING; - $this->assertSame(-1, $arr[-1]); - $this->assertEquals(1, count($arr)); - unset($arr[MAX_UINT32_STRING]); - $this->assertEquals(0, count($arr)); - - $arr['7'] = '7'; - $this->assertSame(7, $arr[7]); - $arr['3.1'] = '3.1'; - $this->assertSame(3, $arr[3]); - $arr['-1.0'] = '-1.0'; - $this->assertSame(-1, $arr[-1]); - $arr[MIN_UINT32_STRING] = MIN_UINT32_STRING; - $this->assertSame(MIN_UINT32, $arr[MIN_UINT32]); - $this->assertEquals(4, count($arr)); - unset($arr['7']); - unset($arr['3.1']); - unset($arr['-1.0']); - unset($arr[MIN_UINT32_STRING]); - $this->assertEquals(0, count($arr)); - } - - ######################################################### - # Test int64 field. - ######################################################### - - public function testInt64() { - $arr = new MapField(GPBType::INT64, GPBType::INT64); - - // Test integer argument. - $arr[MAX_INT64] = MAX_INT64; - $arr[MIN_INT64] = MIN_INT64; - if (PHP_INT_SIZE == 4) { - $this->assertSame(MAX_INT64_STRING, $arr[MAX_INT64_STRING]); - $this->assertSame(MIN_INT64_STRING, $arr[MIN_INT64_STRING]); - } else { - $this->assertSame(MAX_INT64, $arr[MAX_INT64]); - $this->assertSame(MIN_INT64, $arr[MIN_INT64]); - } - $this->assertEquals(2, count($arr)); - unset($arr[MAX_INT64]); - unset($arr[MIN_INT64]); - $this->assertEquals(0, count($arr)); - - // Test float argument. - $arr[1.1] = 1.1; - if (PHP_INT_SIZE == 4) { - $this->assertSame('1', $arr['1']); - } else { - $this->assertSame(1, $arr[1]); - } - $this->assertEquals(1, count($arr)); - unset($arr[1.1]); - $this->assertEquals(0, count($arr)); - - // Test string argument. - $arr['2'] = '2'; - $arr['3.1'] = '3.1'; - $arr[MAX_INT64_STRING] = MAX_INT64_STRING; - $arr[MIN_INT64_STRING] = MIN_INT64_STRING; - if (PHP_INT_SIZE == 4) { - $this->assertSame('2', $arr['2']); - $this->assertSame('3', $arr['3']); - $this->assertSame(MAX_INT64_STRING, $arr[MAX_INT64_STRING]); - $this->assertSame(MIN_INT64_STRING, $arr[MIN_INT64_STRING]); - } else { - $this->assertSame(2, $arr[2]); - $this->assertSame(3, $arr[3]); - $this->assertSame(MAX_INT64, $arr[MAX_INT64]); - $this->assertSame(MIN_INT64, $arr[MIN_INT64]); - } - $this->assertEquals(4, count($arr)); - unset($arr['2']); - unset($arr['3.1']); - unset($arr[MAX_INT64_STRING]); - unset($arr[MIN_INT64_STRING]); - $this->assertEquals(0, count($arr)); - } - - ######################################################### - # Test uint64 field. - ######################################################### - - public function testUint64() { - $arr = new MapField(GPBType::UINT64, GPBType::UINT64); - - // Test integer argument. - $arr[MAX_UINT64] = MAX_UINT64; - if (PHP_INT_SIZE == 4) { - $this->assertSame(MAX_UINT64_STRING, $arr[MAX_UINT64_STRING]); - } else { - $this->assertSame(MAX_UINT64, $arr[MAX_UINT64]); - } - $this->assertEquals(1, count($arr)); - unset($arr[MAX_UINT64]); - $this->assertEquals(0, count($arr)); - - // Test float argument. - $arr[1.1] = 1.1; - if (PHP_INT_SIZE == 4) { - $this->assertSame('1', $arr['1']); - } else { - $this->assertSame(1, $arr[1]); - } - $this->assertEquals(1, count($arr)); - unset($arr[1.1]); - $this->assertEquals(0, count($arr)); - - // Test string argument. - $arr['2'] = '2'; - $arr['3.1'] = '3.1'; - $arr[MAX_UINT64_STRING] = MAX_UINT64_STRING; - - if (PHP_INT_SIZE == 4) { - $this->assertSame('2', $arr['2']); - $this->assertSame('3', $arr['3']); - $this->assertSame(MAX_UINT64_STRING, $arr[MAX_UINT64_STRING]); - } else { - $this->assertSame(2, $arr[2]); - $this->assertSame(3, $arr[3]); - $this->assertSame(MAX_UINT64, $arr[MAX_UINT64]); - } - - $this->assertEquals(3, count($arr)); - unset($arr['2']); - unset($arr['3.1']); - unset($arr[MAX_UINT64_STRING]); - $this->assertEquals(0, count($arr)); - } - - ######################################################### - # Test float field. - ######################################################### - - public function testFloat() { - $arr = new MapField(GPBType::INT32, GPBType::FLOAT); - - // Test set. - $arr[0] = 1; - $this->assertEquals(1.0, $arr[0], '', MAX_FLOAT_DIFF); - - $arr[1] = 1.1; - $this->assertEquals(1.1, $arr[1], '', MAX_FLOAT_DIFF); - - $arr[2] = '2'; - $this->assertEquals(2.0, $arr[2], '', MAX_FLOAT_DIFF); - $arr[3] = '3.1'; - $this->assertEquals(3.1, $arr[3], '', MAX_FLOAT_DIFF); - - $this->assertEquals(4, count($arr)); - } - - ######################################################### - # Test double field. - ######################################################### - - public function testDouble() { - $arr = new MapField(GPBType::INT32, GPBType::DOUBLE); - - // Test set. - $arr[0] = 1; - $this->assertEquals(1.0, $arr[0], '', MAX_FLOAT_DIFF); - - $arr[1] = 1.1; - $this->assertEquals(1.1, $arr[1], '', MAX_FLOAT_DIFF); - - $arr[2] = '2'; - $this->assertEquals(2.0, $arr[2], '', MAX_FLOAT_DIFF); - $arr[3] = '3.1'; - $this->assertEquals(3.1, $arr[3], '', MAX_FLOAT_DIFF); - - $this->assertEquals(4, count($arr)); - } - - ######################################################### - # Test bool field. - ######################################################### - - public function testBool() { - $arr = new MapField(GPBType::BOOL, GPBType::BOOL); - - // Test boolean. - $arr[True] = True; - $this->assertSame(True, $arr[True]); - $this->assertEquals(1, count($arr)); - unset($arr[True]); - $this->assertEquals(0, count($arr)); - - $arr[False] = False; - $this->assertSame(False, $arr[False]); - $this->assertEquals(1, count($arr)); - unset($arr[False]); - $this->assertEquals(0, count($arr)); - - // Test integer. - $arr[-1] = -1; - $this->assertSame(True, $arr[True]); - $this->assertEquals(1, count($arr)); - unset($arr[-1]); - $this->assertEquals(0, count($arr)); - - $arr[0] = 0; - $this->assertSame(False, $arr[False]); - $this->assertEquals(1, count($arr)); - unset($arr[0]); - $this->assertEquals(0, count($arr)); - - // Test float. - $arr[1.1] = 1.1; - $this->assertSame(True, $arr[True]); - $this->assertEquals(1, count($arr)); - unset($arr[1.1]); - $this->assertEquals(0, count($arr)); - - $arr[0.0] = 0.0; - $this->assertSame(False, $arr[False]); - $this->assertEquals(1, count($arr)); - unset($arr[0.0]); - $this->assertEquals(0, count($arr)); - - // Test string. - $arr['a'] = 'a'; - $this->assertSame(True, $arr[True]); - $this->assertEquals(1, count($arr)); - unset($arr['a']); - $this->assertEquals(0, count($arr)); - - $arr[''] = ''; - $this->assertSame(False, $arr[False]); - $this->assertEquals(1, count($arr)); - unset($arr['']); - $this->assertEquals(0, count($arr)); - } - - ######################################################### - # Test string field. - ######################################################### - - public function testString() { - $arr = new MapField(GPBType::STRING, GPBType::STRING); - - // Test set. - $arr['abc'] = 'abc'; - $this->assertSame('abc', $arr['abc']); - $this->assertEquals(1, count($arr)); - unset($arr['abc']); - $this->assertEquals(0, count($arr)); - - $arr[1] = 1; - $this->assertSame('1', $arr['1']); - $this->assertEquals(1, count($arr)); - unset($arr[1]); - $this->assertEquals(0, count($arr)); - - $arr[1.1] = 1.1; - $this->assertSame('1.1', $arr['1.1']); - $this->assertEquals(1, count($arr)); - unset($arr[1.1]); - $this->assertEquals(0, count($arr)); - - $arr[True] = True; - $this->assertSame('1', $arr['1']); - $this->assertEquals(1, count($arr)); - unset($arr[True]); - $this->assertEquals(0, count($arr)); - - // Test foreach. - $arr = new MapField(GPBType::STRING, GPBType::STRING); - for ($i = 0; $i < 3; $i++) { - $arr[$i] = $i; - } - $i = 0; - $arr_test = []; - foreach ($arr as $key => $val) { - $this->assertSame($key, $val); - $arr_test[] = $key; - $i++; - } - $this->assertTrue(isset($arr_test['0'])); - $this->assertTrue(isset($arr_test['1'])); - $this->assertTrue(isset($arr_test['2'])); - $this->assertSame(3, $i); - } - - ######################################################### - # Test message field. - ######################################################### - - public function testMessage() { - $arr = new MapField(GPBType::INT32, - GPBType::MESSAGE, TestMessage_Sub::class); - - // Test append. - $sub_m = new TestMessage_Sub(); - $sub_m->setA(1); - $arr[0] = $sub_m; - $this->assertSame(1, $arr[0]->getA()); - - $this->assertEquals(1, count($arr)); - - // Test foreach. - $arr = new MapField(GPBType::INT32, - GPBType::MESSAGE, TestMessage_Sub::class); - for ($i = 0; $i < 3; $i++) { - $arr[$i] = new TestMessage_Sub();; - $arr[$i]->setA($i); - } - $i = 0; - $key_test = []; - $value_test = []; - foreach ($arr as $key => $val) { - $key_test[] = $key; - $value_test[] = $val->getA(); - $i++; - } - $this->assertTrue(isset($key_test['0'])); - $this->assertTrue(isset($key_test['1'])); - $this->assertTrue(isset($key_test['2'])); - $this->assertTrue(isset($value_test['0'])); - $this->assertTrue(isset($value_test['1'])); - $this->assertTrue(isset($value_test['2'])); - $this->assertSame(3, $i); - } - - ######################################################### - # Test memory leak - ######################################################### - - // TODO(teboring): Add it back. - // public function testCycleLeak() - // { - // $arr = new MapField(GPBType::INT32, - // GPBType::MESSAGE, TestMessage::class); - // $arr[0] = new TestMessage; - // $arr[0]->SetMapRecursive($arr); - - // // Clean up memory before test. - // gc_collect_cycles(); - // $start = memory_get_usage(); - // unset($arr); - - // // Explicitly trigger garbage collection. - // gc_collect_cycles(); - - // $end = memory_get_usage(); - // $this->assertLessThan($start, $end); - // } -} diff --git a/third_party/protobuf/3.4.0/php/tests/memory_leak_test.php b/third_party/protobuf/3.4.0/php/tests/memory_leak_test.php deleted file mode 100644 index a92694d05c..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/memory_leak_test.php +++ /dev/null @@ -1,106 +0,0 @@ -<?php - -# phpunit has memory leak by itself. Thus, it cannot be used to test memory leak. - -require_once('generated/NoNamespaceEnum.php'); -require_once('generated/NoNamespaceMessage.php'); -require_once('generated/NoNamespaceMessage_NestedEnum.php'); -require_once('generated/PrefixEmpty.php'); -require_once('generated/PrefixTestPrefix.php'); -require_once('generated/TestEmptyNamespace.php'); -require_once('generated/Bar/TestInclude.php'); -require_once('generated/Foo/PBARRAY.php'); -require_once('generated/Foo/PBEmpty.php'); -require_once('generated/Foo/TestEnum.php'); -require_once('generated/Foo/TestIncludeNamespaceMessage.php'); -require_once('generated/Foo/TestIncludePrefixMessage.php'); -require_once('generated/Foo/TestMessage.php'); -require_once('generated/Foo/TestMessage_Empty.php'); -require_once('generated/Foo/TestMessage_NestedEnum.php'); -require_once('generated/Foo/TestMessage_Sub.php'); -require_once('generated/Foo/TestPackedMessage.php'); -require_once('generated/Foo/TestPhpDoc.php'); -require_once('generated/Foo/TestRandomFieldOrder.php'); -require_once('generated/Foo/TestReverseFieldOrder.php'); -require_once('generated/Foo/TestUnpackedMessage.php'); -require_once('generated/GPBMetadata/Proto/Test.php'); -require_once('generated/GPBMetadata/Proto/TestEmptyPhpNamespace.php'); -require_once('generated/GPBMetadata/Proto/TestInclude.php'); -require_once('generated/GPBMetadata/Proto/TestNoNamespace.php'); -require_once('generated/GPBMetadata/Proto/TestPhpNamespace.php'); -require_once('generated/GPBMetadata/Proto/TestPrefix.php'); -require_once('generated/Php/Test/TestNamespace.php'); -require_once('test_util.php'); - -use Google\Protobuf\Internal\RepeatedField; -use Google\Protobuf\Internal\GPBType; -use Foo\TestMessage; -use Foo\TestMessage_Sub; - -$from = new TestMessage(); -TestUtil::setTestMessage($from); -TestUtil::assertTestMessage($from); - -$data = $from->serializeToString(); - -$to = new TestMessage(); -$to->mergeFromString($data); - -TestUtil::assertTestMessage($to); - -$from->setRecursive($from); - -$arr = new RepeatedField(GPBType::MESSAGE, TestMessage::class); -$arr[] = new TestMessage; -$arr[0]->SetRepeatedRecursive($arr); - -// Test oneof fields. -$m = new TestMessage(); - -$m->setOneofInt32(1); -assert(1 === $m->getOneofInt32()); -assert(0.0 === $m->getOneofFloat()); -assert('' === $m->getOneofString()); -assert(NULL === $m->getOneofMessage()); -$data = $m->serializeToString(); -$n = new TestMessage(); -$n->mergeFromString($data); -assert(1 === $n->getOneofInt32()); - -$m->setOneofFloat(2.0); -assert(0 === $m->getOneofInt32()); -assert(2.0 === $m->getOneofFloat()); -assert('' === $m->getOneofString()); -assert(NULL === $m->getOneofMessage()); -$data = $m->serializeToString(); -$n = new TestMessage(); -$n->mergeFromString($data); -assert(2.0 === $n->getOneofFloat()); - -$m->setOneofString('abc'); -assert(0 === $m->getOneofInt32()); -assert(0.0 === $m->getOneofFloat()); -assert('abc' === $m->getOneofString()); -assert(NULL === $m->getOneofMessage()); -$data = $m->serializeToString(); -$n = new TestMessage(); -$n->mergeFromString($data); -assert('abc' === $n->getOneofString()); - -$sub_m = new TestMessage_Sub(); -$sub_m->setA(1); -$m->setOneofMessage($sub_m); -assert(0 === $m->getOneofInt32()); -assert(0.0 === $m->getOneofFloat()); -assert('' === $m->getOneofString()); -assert(1 === $m->getOneofMessage()->getA()); -$data = $m->serializeToString(); -$n = new TestMessage(); -$n->mergeFromString($data); -assert(1 === $n->getOneofMessage()->getA()); - -# $from = new TestMessage(); -# $to = new TestMessage(); -# TestUtil::setTestMessage($from); -# $to->mergeFrom($from); -# TestUtil::assertTestMessage($to); diff --git a/third_party/protobuf/3.4.0/php/tests/php_implementation_test.php b/third_party/protobuf/3.4.0/php/tests/php_implementation_test.php deleted file mode 100644 index 5dbc9233cf..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/php_implementation_test.php +++ /dev/null @@ -1,516 +0,0 @@ -<?php - -require_once('test_base.php'); -require_once('test_util.php'); - -use Foo\TestMessage; -use Foo\TestMessage_Sub; -use Foo\TestPackedMessage; -use Google\Protobuf\Internal\CodedInputStream; -use Google\Protobuf\Internal\FileDescriptorSet; -use Google\Protobuf\Internal\GPBLabel; -use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\CodedOutputStream; - -class ImplementationTest extends TestBase -{ - - public function testReadInt32() - { - $value = null; - - // Positive number. - $input = new CodedInputStream(hex2bin("01")); - GPBWire::readInt32($input, $value); - $this->assertSame(1, $value); - - // Negative number. - $input = new CodedInputStream(hex2bin("ffffffff0f")); - GPBWire::readInt32($input, $value); - $this->assertSame(-1, $value); - - // Discard overflow bits. - $input = new CodedInputStream(hex2bin("ffffffff7f")); - GPBWire::readInt32($input, $value); - $this->assertSame(-1, $value); - } - - public function testReadUint32() - { - $value = null; - - // Positive number. - $input = new CodedInputStream(hex2bin("01")); - GPBWire::readUint32($input, $value); - $this->assertSame(1, $value); - - // Max uint32. - $input = new CodedInputStream(hex2bin("ffffffff0f")); - GPBWire::readUint32($input, $value); - $this->assertSame(-1, $value); - - // Discard overflow bits. - $input = new CodedInputStream(hex2bin("ffffffff7f")); - GPBWire::readUint32($input, $value); - $this->assertSame(-1, $value); - } - - public function testReadInt64() - { - $value = null; - - // Positive number. - $input = new CodedInputStream(hex2bin("01")); - GPBWire::readInt64($input, $value); - $this->assertEquals(1, $value); - - // Negative number. - $input = new CodedInputStream(hex2bin("ffffffffffffffffff01")); - GPBWire::readInt64($input, $value); - $this->assertEquals(-1, $value); - - // Discard overflow bits. - $input = new CodedInputStream(hex2bin("ffffffffffffffffff0f")); - GPBWire::readInt64($input, $value); - $this->assertEquals(-1, $value); - } - - public function testReadUint64() - { - $value = null; - - // Positive number. - $input = new CodedInputStream(hex2bin("01")); - GPBWire::readUint64($input, $value); - $this->assertEquals(1, $value); - - // Negative number. - $input = new CodedInputStream(hex2bin("FFFFFFFFFFFFFFFFFF01")); - GPBWire::readUint64($input, $value); - $this->assertEquals(-1, $value); - - // Discard overflow bits. - $input = new CodedInputStream(hex2bin("FFFFFFFFFFFFFFFFFF0F")); - GPBWire::readUint64($input, $value); - $this->assertEquals(-1, $value); - } - - public function testReadSint32() - { - $value = null; - - $input = new CodedInputStream(hex2bin("00")); - GPBWire::readSint32($input, $value); - $this->assertSame(0, $value); - - $input = new CodedInputStream(hex2bin("01")); - GPBWire::readSint32($input, $value); - $this->assertSame(-1, $value); - - $input = new CodedInputStream(hex2bin("02")); - GPBWire::readSint32($input, $value); - $this->assertSame(1, $value); - } - - public function testReadSint64() - { - $value = null; - - $input = new CodedInputStream(hex2bin("00")); - GPBWire::readSint64($input, $value); - $this->assertEquals(0, $value); - - $input = new CodedInputStream(hex2bin("01")); - GPBWire::readSint64($input, $value); - $this->assertEquals(-1, $value); - - $input = new CodedInputStream(hex2bin("02")); - GPBWire::readSint64($input, $value); - $this->assertEquals(1, $value); - } - - public function testReadFixed32() - { - $value = null; - $input = new CodedInputStream(hex2bin("12345678")); - GPBWire::readFixed32($input, $value); - $this->assertSame(0x78563412, $value); - } - - public function testReadFixed64() - { - $value = null; - $input = new CodedInputStream(hex2bin("1234567812345678")); - GPBWire::readFixed64($input, $value); - if (PHP_INT_SIZE == 4) { - $this->assertSame("8671175386481439762", $value); - } else { - $this->assertSame(0x7856341278563412, $value); - } - } - - public function testReadSfixed32() - { - $value = null; - $input = new CodedInputStream(hex2bin("12345678")); - GPBWire::readSfixed32($input, $value); - $this->assertSame(0x78563412, $value); - } - - public function testReadFloat() - { - $value = null; - $input = new CodedInputStream(hex2bin("0000803F")); - GPBWire::readFloat($input, $value); - $this->assertSame(1.0, $value); - } - - public function testReadBool() - { - $value = null; - - $input = new CodedInputStream(hex2bin("00")); - GPBWire::readBool($input, $value); - $this->assertSame(false, $value); - - $input = new CodedInputStream(hex2bin("01")); - GPBWire::readBool($input, $value); - $this->assertSame(true, $value); - } - - public function testReadDouble() - { - $value = null; - $input = new CodedInputStream(hex2bin("000000000000F03F")); - GPBWire::readDouble($input, $value); - $this->assertSame(1.0, $value); - } - - public function testReadSfixed64() - { - $value = null; - $input = new CodedInputStream(hex2bin("1234567812345678")); - GPBWire::readSfixed64($input, $value); - if (PHP_INT_SIZE == 4) { - $this->assertSame("8671175386481439762", $value); - } else { - $this->assertSame(0x7856341278563412, $value); - } - } - - public function testZigZagEncodeDecode() - { - $this->assertSame(0, GPBWire::zigZagEncode32(0)); - $this->assertSame(1, GPBWire::zigZagEncode32(-1)); - $this->assertSame(2, GPBWire::zigZagEncode32(1)); - $this->assertSame(3, GPBWire::zigZagEncode32(-2)); - $this->assertSame(0x7FFFFFFE, GPBWire::zigZagEncode32(0x3FFFFFFF)); - $this->assertSame(0x7FFFFFFF, GPBWire::zigZagEncode32(0xC0000000)); - $this->assertSame(0x7FFFFFFF, GPBWire::zigZagEncode32(-1073741824)); - - $this->assertSame(0, GPBWire::zigZagDecode32(0)); - $this->assertSame(-1, GPBWire::zigZagDecode32(1)); - $this->assertSame(1, GPBWire::zigZagDecode32(2)); - $this->assertSame(-2, GPBWire::zigZagDecode32(3)); - $this->assertSame(0x3FFFFFFF, GPBWire::zigZagDecode32(0x7FFFFFFE)); - $this->assertSame(-1073741824, GPBWire::zigZagDecode32(0x7FFFFFFF)); - $this->assertSame(0x7FFFFFFF, GPBWire::zigZagDecode32(0xFFFFFFFE)); - $this->assertSame((int)-2147483648,GPBWire::zigZagDecode32(0xFFFFFFFF)); - - if (PHP_INT_SIZE == 4) { - $this->assertSame(-2, GPBWire::zigZagEncode32(0x7FFFFFFF)); - $this->assertSame(-1, GPBWire::zigZagEncode32(0x80000000)); - $this->assertSame('0', GPBWire::zigZagEncode64(0)); - $this->assertSame('1', GPBWire::zigZagEncode64(-1)); - $this->assertSame('2', GPBWire::zigZagEncode64(1)); - $this->assertSame('3', GPBWire::zigZagEncode64(-2)); - $this->assertSame( - '2147483646', // 0x7FFFFFE - GPBWire::zigZagEncode64(0x3FFFFFFF)); - $this->assertSame( - '2147483647', // 0x7FFFFFF - GPBWire::zigZagEncode64(-1073741824)); // 0xFFFFFFFFC0000000 - $this->assertSame( - '4294967294', // 0xFFFFFFFE - GPBWire::zigZagEncode64(2147483647)); // 0x7FFFFFFF - $this->assertSame( - '4294967295', // 0xFFFFFFFF - GPBWire::zigZagEncode64(-2147483648)); // 0xFFFFFFFF80000000 - $this->assertSame( - '18446744073709551614', // 0xFFFFFFFFFFFFFFFE - // 0x7FFFFFFFFFFFFFFF - GPBWire::zigZagEncode64("9223372036854775807")); - $this->assertSame( - '18446744073709551615', // 0xFFFFFFFFFFFFFFFF - // 0x8000000000000000 - GPBWire::zigZagEncode64("-9223372036854775808")); - - $this->assertSame('0', GPBWire::zigZagDecode64(0)); - $this->assertSame('-1', GPBWire::zigZagDecode64(1)); - $this->assertSame('1', GPBWire::zigZagDecode64(2)); - $this->assertSame('-2', GPBWire::zigZagDecode64(3)); - } else { - $this->assertSame(4294967294, GPBWire::zigZagEncode32(0x7FFFFFFF)); - $this->assertSame(4294967295, GPBWire::zigZagEncode32(0x80000000)); - $this->assertSame(0, GPBWire::zigZagEncode64(0)); - $this->assertSame(1, GPBWire::zigZagEncode64(-1)); - $this->assertSame(2, GPBWire::zigZagEncode64(1)); - $this->assertSame(3, GPBWire::zigZagEncode64(-2)); - $this->assertSame(0x7FFFFFFE, GPBWire::zigZagEncode64(0x3FFFFFFF)); - $this->assertSame( - 0x7FFFFFFF, - GPBWire::zigZagEncode64(0xFFFFFFFFC0000000)); - $this->assertSame( - 0xFFFFFFFE, - GPBWire::zigZagEncode64(0x7FFFFFFF)); - $this->assertSame( - 0xFFFFFFFF, - GPBWire::zigZagEncode64(0xFFFFFFFF80000000)); - $this->assertSame( - -2, // 0xFFFFFFFFFFFFFFFE - GPBWire::zigZagEncode64(0x7FFFFFFFFFFFFFFF)); - $this->assertSame( - -1, // 0xFFFFFFFFFFFFFFFF - GPBWire::zigZagEncode64(0x8000000000000000)); - - $this->assertSame(0, GPBWire::zigZagDecode64(0)); - $this->assertSame(-1, GPBWire::zigZagDecode64(1)); - $this->assertSame(1, GPBWire::zigZagDecode64(2)); - $this->assertSame(-2, GPBWire::zigZagDecode64(3)); - } - - // Round trip - $this->assertSame(0, GPBWire::zigZagDecode32(GPBWire::zigZagEncode32(0))); - $this->assertSame(1, GPBWire::zigZagDecode32(GPBWire::zigZagEncode32(1))); - $this->assertSame(-1, GPBWire::zigZagDecode32(GPBWire::zigZagEncode32(-1))); - $this->assertSame(14927, - GPBWire::zigZagDecode32(GPBWire::zigZagEncode32(14927))); - $this->assertSame(-3612, - GPBWire::zigZagDecode32(GPBWire::zigZagEncode32(-3612))); - } - - public function testDecode() - { - $m = new TestMessage(); - $m->mergeFromString(TestUtil::getGoldenTestMessage()); - TestUtil::assertTestMessage($m); - } - - public function testDescriptorDecode() - { - $file_desc_set = new FileDescriptorSet(); - $file_desc_set->mergeFromString(hex2bin( - "0a3b0a12746573745f696e636c7564652e70726f746f120362617222180a" . - "0b54657374496e636c75646512090a0161180120012805620670726f746f33")); - - $this->assertSame(1, sizeof($file_desc_set->getFile())); - - $file_desc = $file_desc_set->getFile()[0]; - $this->assertSame("test_include.proto", $file_desc->getName()); - $this->assertSame("bar", $file_desc->getPackage()); - $this->assertSame(0, sizeof($file_desc->getDependency())); - $this->assertSame(1, sizeof($file_desc->getMessageType())); - $this->assertSame(0, sizeof($file_desc->getEnumType())); - $this->assertSame("proto3", $file_desc->getSyntax()); - - $desc = $file_desc->getMessageType()[0]; - $this->assertSame("TestInclude", $desc->getName()); - $this->assertSame(1, sizeof($desc->getField())); - $this->assertSame(0, sizeof($desc->getNestedType())); - $this->assertSame(0, sizeof($desc->getEnumType())); - $this->assertSame(0, sizeof($desc->getOneofDecl())); - - $field = $desc->getField()[0]; - $this->assertSame("a", $field->getName()); - $this->assertSame(1, $field->getNumber()); - $this->assertSame(GPBLabel::OPTIONAL, $field->getLabel()); - $this->assertSame(GPBType::INT32, $field->getType()); - } - - public function testReadVarint64() - { - $var = 0; - - // Empty buffer. - $input = new CodedInputStream(hex2bin('')); - $this->assertFalse($input->readVarint64($var)); - - // The largest varint is 10 bytes long. - $input = new CodedInputStream(hex2bin('8080808080808080808001')); - $this->assertFalse($input->readVarint64($var)); - - // Corrupted varint. - $input = new CodedInputStream(hex2bin('808080')); - $this->assertFalse($input->readVarint64($var)); - - // Normal case. - $input = new CodedInputStream(hex2bin('808001')); - $this->assertTrue($input->readVarint64($var)); - if (PHP_INT_SIZE == 4) { - $this->assertSame('16384', $var); - } else { - $this->assertSame(16384, $var); - } - $this->assertFalse($input->readVarint64($var)); - - // Read two varint. - $input = new CodedInputStream(hex2bin('808001808002')); - $this->assertTrue($input->readVarint64($var)); - if (PHP_INT_SIZE == 4) { - $this->assertSame('16384', $var); - } else { - $this->assertSame(16384, $var); - } - $this->assertTrue($input->readVarint64($var)); - if (PHP_INT_SIZE == 4) { - $this->assertSame('32768', $var); - } else { - $this->assertSame(32768, $var); - } - $this->assertFalse($input->readVarint64($var)); - - // Read 64 testing - $testVals = array( - '10' => '0a000000000000000000', - '100' => '64000000000000000000', - '800' => 'a0060000000000000000', - '6400' => '80320000000000000000', - '70400' => '80a60400000000000000', - '774400' => '80a22f00000000000000', - '9292800' => '8098b704000000000000', - '74342400' => '80c0b923000000000000', - '743424000' => '8080bfe2020000000000', - '8177664000' => '8080b5bb1e0000000000', - '65421312000' => '8080a8dbf30100000000', - '785055744000' => '8080e0c7ec1600000000', - '9420668928000' => '808080dd969202000000', - '103627358208000' => '808080fff9c717000000', - '1139900940288000' => '808080f5bd9783020000', - '13678811283456000' => '808080fce699a6180000', - '109430490267648000' => '808080e0b7ceb1c20100', - '984874412408832000' => '808080e0f5c1bed50d00', - ); - - foreach ($testVals as $original => $encoded) { - $input = new CodedInputStream(hex2bin($encoded)); - $this->assertTrue($input->readVarint64($var)); - $this->assertEquals($original, $var); - } - } - - public function testReadVarint32() - { - $var = 0; - - // Empty buffer. - $input = new CodedInputStream(hex2bin('')); - $this->assertFalse($input->readVarint32($var)); - - // The largest varint is 10 bytes long. - $input = new CodedInputStream(hex2bin('8080808080808080808001')); - $this->assertFalse($input->readVarint32($var)); - - // Corrupted varint. - $input = new CodedInputStream(hex2bin('808080')); - $this->assertFalse($input->readVarint32($var)); - - // Normal case. - $input = new CodedInputStream(hex2bin('808001')); - $this->assertTrue($input->readVarint32($var)); - $this->assertSame(16384, $var); - $this->assertFalse($input->readVarint32($var)); - - // Read two varint. - $input = new CodedInputStream(hex2bin('808001808002')); - $this->assertTrue($input->readVarint32($var)); - $this->assertSame(16384, $var); - $this->assertTrue($input->readVarint32($var)); - $this->assertSame(32768, $var); - $this->assertFalse($input->readVarint32($var)); - - // Read a 64-bit integer. High-order bits should be discarded. - $input = new CodedInputStream(hex2bin('808081808001')); - $this->assertTrue($input->readVarint32($var)); - $this->assertSame(16384, $var); - $this->assertFalse($input->readVarint32($var)); - } - - public function testReadTag() - { - $input = new CodedInputStream(hex2bin('808001')); - $tag = $input->readTag(); - $this->assertSame(16384, $tag); - $tag = $input->readTag(); - $this->assertSame(0, $tag); - } - - public function testPushPopLimit() - { - $input = new CodedInputStream(hex2bin('808001')); - $old_limit = $input->pushLimit(0); - $tag = $input->readTag(); - $this->assertSame(0, $tag); - $input->popLimit($old_limit); - $tag = $input->readTag(); - $this->assertSame(16384, $tag); - } - - public function testReadRaw() - { - $input = new CodedInputStream(hex2bin('808001')); - $buffer = null; - - $this->assertTrue($input->readRaw(3, $buffer)); - $this->assertSame(hex2bin('808001'), $buffer); - - $this->assertFalse($input->readRaw(1, $buffer)); - } - - public function testWriteVarint32() - { - $output = new CodedOutputStream(3); - $output->writeVarint32(16384, true); - $this->assertSame(hex2bin('808001'), $output->getData()); - - // Negative numbers are padded to be compatible with int64. - $output = new CodedOutputStream(10); - $output->writeVarint32(-43, false); - $this->assertSame(hex2bin('D5FFFFFFFFFFFFFFFF01'), $output->getData()); - } - - public function testWriteVarint64() - { - $output = new CodedOutputStream(10); - $output->writeVarint64(-43); - $this->assertSame(hex2bin('D5FFFFFFFFFFFFFFFF01'), $output->getData()); - } - - public function testWriteLittleEndian32() - { - $output = new CodedOutputStream(4); - $output->writeLittleEndian32(46); - $this->assertSame(hex2bin('2E000000'), $output->getData()); - } - - public function testWriteLittleEndian64() - { - $output = new CodedOutputStream(8); - $output->writeLittleEndian64(47); - $this->assertSame(hex2bin('2F00000000000000'), $output->getData()); - } - - public function testByteSize() - { - $m = new TestMessage(); - TestUtil::setTestMessage($m); - $this->assertSame(506, $m->byteSize()); - } - - public function testPackedByteSize() - { - $m = new TestPackedMessage(); - TestUtil::setTestPackedMessage($m); - $this->assertSame(166, $m->byteSize()); - } -} diff --git a/third_party/protobuf/3.4.0/php/tests/proto/test.proto b/third_party/protobuf/3.4.0/php/tests/proto/test.proto deleted file mode 100644 index a90f3d1d7a..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/proto/test.proto +++ /dev/null @@ -1,194 +0,0 @@ -syntax = "proto3"; - -import 'proto/test_include.proto'; -import 'proto/test_no_namespace.proto'; -import 'proto/test_php_namespace.proto'; -import 'proto/test_empty_php_namespace.proto'; -import 'proto/test_prefix.proto'; - -package foo; - -message TestMessage { - // Singular - int32 optional_int32 = 1; - int64 optional_int64 = 2; - uint32 optional_uint32 = 3; - uint64 optional_uint64 = 4; - sint32 optional_sint32 = 5; - sint64 optional_sint64 = 6; - fixed32 optional_fixed32 = 7; - fixed64 optional_fixed64 = 8; - sfixed32 optional_sfixed32 = 9; - sfixed64 optional_sfixed64 = 10; - float optional_float = 11; - double optional_double = 12; - bool optional_bool = 13; - string optional_string = 14; - bytes optional_bytes = 15; - - TestEnum optional_enum = 16; - Sub optional_message = 17; - bar.TestInclude optional_included_message = 18; - TestMessage recursive = 19; - - // Repeated - repeated int32 repeated_int32 = 31; - repeated int64 repeated_int64 = 32; - repeated uint32 repeated_uint32 = 33; - repeated uint64 repeated_uint64 = 34; - repeated sint32 repeated_sint32 = 35; - repeated sint64 repeated_sint64 = 36; - repeated fixed32 repeated_fixed32 = 37; - repeated fixed64 repeated_fixed64 = 38; - repeated sfixed32 repeated_sfixed32 = 39; - repeated sfixed64 repeated_sfixed64 = 40; - repeated float repeated_float = 41; - repeated double repeated_double = 42; - repeated bool repeated_bool = 43; - repeated string repeated_string = 44; - repeated bytes repeated_bytes = 45; - - repeated TestEnum repeated_enum = 46; - repeated Sub repeated_message = 47; - repeated TestMessage repeated_recursive = 48; - - oneof my_oneof { - int32 oneof_int32 = 51; - int64 oneof_int64 = 52; - uint32 oneof_uint32 = 53; - uint64 oneof_uint64 = 54; - uint32 oneof_sint32 = 55; - uint64 oneof_sint64 = 56; - uint32 oneof_fixed32 = 57; - uint64 oneof_fixed64 = 58; - uint32 oneof_sfixed32 = 59; - uint64 oneof_sfixed64 = 60; - double oneof_double = 61; - float oneof_float = 62; - bool oneof_bool = 63; - string oneof_string = 64; - bytes oneof_bytes = 65; - TestEnum oneof_enum = 66; - Sub oneof_message = 67; - } - - map<int32, int32> map_int32_int32 = 71; - map<int64, int64> map_int64_int64 = 72; - map<uint32, uint32> map_uint32_uint32 = 73; - map<uint64, uint64> map_uint64_uint64 = 74; - map<sint32, sint32> map_sint32_sint32 = 75; - map<sint64, sint64> map_sint64_sint64 = 76; - map<fixed32, fixed32> map_fixed32_fixed32 = 77; - map<fixed64, fixed64> map_fixed64_fixed64 = 78; - map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 79; - map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 80; - map<int32, float> map_int32_float = 81; - map<int32, double> map_int32_double = 82; - map<bool, bool> map_bool_bool = 83; - map<string, string> map_string_string = 84; - map<int32, bytes> map_int32_bytes = 85; - map<int32, TestEnum> map_int32_enum = 86; - map<int32, Sub> map_int32_message = 87; - - map<int32, TestMessage> map_recursive = 88; - - message Sub { - int32 a = 1; - repeated int32 b = 2; - } - - // Reserved for non-existing field test. - // int32 non_exist = 89; - - NoNamespaceMessage optional_no_namespace_message = 91; - NoNamespaceEnum optional_no_namespace_enum = 92; - repeated NoNamespaceMessage repeated_no_namespace_message = 93; - repeated NoNamespaceEnum repeated_no_namespace_enum = 94; - - enum NestedEnum { - ZERO = 0; - } - - NestedEnum optional_nested_enum = 101; - - // Test prefix for reserved words. - message Empty { - int32 a = 1; - } -} - -enum TestEnum { - ZERO = 0; - ONE = 1; - TWO = 2; - ECHO = 3; // Test reserved name. -} - -// Test prefix for reserved words. -message Empty { - int32 a = 1; -} - -message ARRAY { - int32 a = 1; -} - -message TestPackedMessage { - repeated int32 repeated_int32 = 90 [packed = true]; - repeated int64 repeated_int64 = 91 [packed = true]; - repeated uint32 repeated_uint32 = 92 [packed = true]; - repeated uint64 repeated_uint64 = 93 [packed = true]; - repeated sint32 repeated_sint32 = 94 [packed = true]; - repeated sint64 repeated_sint64 = 95 [packed = true]; - repeated fixed32 repeated_fixed32 = 96 [packed = true]; - repeated fixed64 repeated_fixed64 = 97 [packed = true]; - repeated sfixed32 repeated_sfixed32 = 98 [packed = true]; - repeated sfixed64 repeated_sfixed64 = 99 [packed = true]; - repeated float repeated_float = 100 [packed = true]; - repeated double repeated_double = 101 [packed = true]; - repeated bool repeated_bool = 102 [packed = true]; - repeated TestEnum repeated_enum = 103 [packed = true]; -} - -// Need to be in sync with TestPackedMessage. -message TestUnpackedMessage { - repeated int32 repeated_int32 = 90 [packed = false]; - repeated int64 repeated_int64 = 91 [packed = false]; - repeated uint32 repeated_uint32 = 92 [packed = false]; - repeated uint64 repeated_uint64 = 93 [packed = false]; - repeated sint32 repeated_sint32 = 94 [packed = false]; - repeated sint64 repeated_sint64 = 95 [packed = false]; - repeated fixed32 repeated_fixed32 = 96 [packed = false]; - repeated fixed64 repeated_fixed64 = 97 [packed = false]; - repeated sfixed32 repeated_sfixed32 = 98 [packed = false]; - repeated sfixed64 repeated_sfixed64 = 99 [packed = false]; - repeated float repeated_float = 100 [packed = false]; - repeated double repeated_double = 101 [packed = false]; - repeated bool repeated_bool = 102 [packed = false]; - repeated TestEnum repeated_enum = 103 [packed = false]; -} - -// /**/@<>&\{ -message TestPhpDoc { - int32 a = 1; -} - -message TestIncludePrefixMessage { - TestPrefix prefix_message = 1; -} - -message TestIncludeNamespaceMessage { - TestNamespace namespace_message = 1; - TestEmptyNamespace empty_namespace_message = 2; -} - -// This will cause upb fields not ordered by the order in the generated code. -message TestRandomFieldOrder { - int64 tag13 = 150; - string tag14 = 160; -} - -message TestReverseFieldOrder { - repeated int32 a = 2; - string b = 1; -} diff --git a/third_party/protobuf/3.4.0/php/tests/proto/test_descriptors.proto b/third_party/protobuf/3.4.0/php/tests/proto/test_descriptors.proto deleted file mode 100644 index d42aec7cec..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/proto/test_descriptors.proto +++ /dev/null @@ -1,35 +0,0 @@ -syntax = "proto3"; - -package descriptors; - -message TestDescriptorsMessage { - int32 optional_int32 = 1; - TestDescriptorsEnum optional_enum = 16; - Sub optional_message = 17; - - // Repeated - repeated int32 repeated_int32 = 31; - repeated Sub repeated_message = 47; - - oneof my_oneof { - int32 oneof_int32 = 51; - } - - map<int32, EnumSub> map_int32_enum = 71; - - message Sub { - int32 a = 1; - repeated int32 b = 2; - } - - enum EnumSub { - ZERO = 0; - ONE = 1; - } -} - -enum TestDescriptorsEnum { - ZERO = 0; - ONE = 1; -} - diff --git a/third_party/protobuf/3.4.0/php/tests/proto/test_empty_php_namespace.proto b/third_party/protobuf/3.4.0/php/tests/proto/test_empty_php_namespace.proto deleted file mode 100644 index 7b4bc74d14..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/proto/test_empty_php_namespace.proto +++ /dev/null @@ -1,8 +0,0 @@ -syntax = "proto3"; - -package foo; -option php_namespace = ""; - -message TestEmptyNamespace { - int32 a = 1; -} diff --git a/third_party/protobuf/3.4.0/php/tests/proto/test_import_descriptor_proto.proto b/third_party/protobuf/3.4.0/php/tests/proto/test_import_descriptor_proto.proto deleted file mode 100644 index 2a19940dec..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/proto/test_import_descriptor_proto.proto +++ /dev/null @@ -1,14 +0,0 @@ -syntax = "proto3"; - -import "google/protobuf/descriptor.proto"; - -message TestImportDescriptorProto { - extend google.protobuf.MethodOptions { - int32 a = 72295727; - } -} - -extend google.protobuf.MethodOptions { - int32 a = 72295728; -} - diff --git a/third_party/protobuf/3.4.0/php/tests/proto/test_include.proto b/third_party/protobuf/3.4.0/php/tests/proto/test_include.proto deleted file mode 100644 index 9844617fa8..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/proto/test_include.proto +++ /dev/null @@ -1,7 +0,0 @@ -syntax = "proto3"; - -package bar; - -message TestInclude { - int32 a = 1; -} diff --git a/third_party/protobuf/3.4.0/php/tests/proto/test_no_namespace.proto b/third_party/protobuf/3.4.0/php/tests/proto/test_no_namespace.proto deleted file mode 100644 index 58f13d47bc..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/proto/test_no_namespace.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; - -message NoNamespaceMessage { - int32 a = 1; - - enum NestedEnum { - ZERO = 0; - } - NestedEnum b = 2; - repeated NestedEnum c = 3; -} - -enum NoNamespaceEnum { - VALUE_A = 0; - VALUE_B = 1; -} diff --git a/third_party/protobuf/3.4.0/php/tests/proto/test_php_namespace.proto b/third_party/protobuf/3.4.0/php/tests/proto/test_php_namespace.proto deleted file mode 100644 index 713187b9b0..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/proto/test_php_namespace.proto +++ /dev/null @@ -1,8 +0,0 @@ -syntax = "proto3"; - -package foo; -option php_namespace = "Php\\Test"; - -message TestNamespace { - int32 a = 1; -} diff --git a/third_party/protobuf/3.4.0/php/tests/proto/test_prefix.proto b/third_party/protobuf/3.4.0/php/tests/proto/test_prefix.proto deleted file mode 100644 index 9bfbad7f82..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/proto/test_prefix.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = "proto3"; - -option php_class_prefix = "Prefix"; - -message TestPrefix { - int32 a = 1; -} - -// Test prefix for reserved words. -message Empty { - int32 a = 1; -} diff --git a/third_party/protobuf/3.4.0/php/tests/proto/test_service.proto b/third_party/protobuf/3.4.0/php/tests/proto/test_service.proto deleted file mode 100644 index a03dbc46d7..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/proto/test_service.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto3"; - -package foo; - -option php_generic_services = true; - -service Greeter { - rpc SayHello (HelloRequest) returns (HelloReply) {} - rpc SayHelloAgain (HelloRequest) returns (HelloReply) {} -} - -message HelloRequest { - string name = 1; -} - -message HelloReply { - string message = 1; -} diff --git a/third_party/protobuf/3.4.0/php/tests/proto/test_service_namespace.proto b/third_party/protobuf/3.4.0/php/tests/proto/test_service_namespace.proto deleted file mode 100644 index 719aa484ef..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/proto/test_service_namespace.proto +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto3"; - -import "proto/test_service.proto"; - -package foo; - -option php_generic_services = true; -option php_namespace = "Bar"; - -service OtherGreeter { - rpc SayHello (HelloRequest) returns (HelloReply) {} - rpc SayHelloAgain (HelloRequest) returns (HelloReply) {} -} diff --git a/third_party/protobuf/3.4.0/php/tests/test.sh b/third_party/protobuf/3.4.0/php/tests/test.sh deleted file mode 100755 index c35372d308..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/test.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -# Compile c extension -pushd ../ext/google/protobuf/ -make clean || true -set -e -# Add following in configure for debug: --enable-debug CFLAGS='-g -O0' -phpize && ./configure CFLAGS='-g -O0' && make -popd - -tests=( array_test.php encode_decode_test.php generated_class_test.php generated_phpdoc_test.php map_field_test.php well_known_test.php generated_service_test.php descriptors_test.php ) - -for t in "${tests[@]}" -do - echo "****************************" - echo "* $t" - echo "****************************" - php -dextension=../ext/google/protobuf/modules/protobuf.so `which phpunit` --bootstrap autoload.php $t - echo "" -done - -# # Make sure to run the memory test in debug mode. -# php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php - -export ZEND_DONT_UNLOAD_MODULES=1 -export USE_ZEND_ALLOC=0 -valgrind --leak-check=yes php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php diff --git a/third_party/protobuf/3.4.0/php/tests/test_base.php b/third_party/protobuf/3.4.0/php/tests/test_base.php deleted file mode 100644 index dc5e73f579..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/test_base.php +++ /dev/null @@ -1,342 +0,0 @@ -<?php - -use Foo\TestMessage; -use Foo\TestEnum; -use Foo\TestMessage_Sub; - -class TestBase extends PHPUnit_Framework_TestCase -{ - - public function setFields(TestMessage $m) - { - TestUtil::setTestMessage($m); - } - - public function setFields2(TestMessage $m) - { - TestUtil::setTestMessage2($m); - } - - public function expectFields(TestMessage $m) - { - $this->assertSame(-42, $m->getOptionalInt32()); - $this->assertSame(42, $m->getOptionalUint32()); - $this->assertSame(-44, $m->getOptionalSint32()); - $this->assertSame(46, $m->getOptionalFixed32()); - $this->assertSame(-46, $m->getOptionalSfixed32()); - $this->assertSame(1.5, $m->getOptionalFloat()); - $this->assertSame(1.6, $m->getOptionalDouble()); - $this->assertSame(true, $m->getOptionalBool()); - $this->assertSame('a', $m->getOptionalString()); - $this->assertSame('b', $m->getOptionalBytes()); - $this->assertSame(TestEnum::ONE, $m->getOptionalEnum()); - $this->assertSame(33, $m->getOptionalMessage()->getA()); - if (PHP_INT_SIZE == 4) { - $this->assertSame('-43', $m->getOptionalInt64()); - $this->assertSame('43', $m->getOptionalUint64()); - $this->assertSame('-45', $m->getOptionalSint64()); - $this->assertSame('47', $m->getOptionalFixed64()); - $this->assertSame('-47', $m->getOptionalSfixed64()); - } else { - $this->assertSame(-43, $m->getOptionalInt64()); - $this->assertSame(43, $m->getOptionalUint64()); - $this->assertSame(-45, $m->getOptionalSint64()); - $this->assertSame(47, $m->getOptionalFixed64()); - $this->assertSame(-47, $m->getOptionalSfixed64()); - } - - $this->assertEquals(-42, $m->getRepeatedInt32()[0]); - $this->assertEquals(42, $m->getRepeatedUint32()[0]); - $this->assertEquals(-43, $m->getRepeatedInt64()[0]); - $this->assertEquals(43, $m->getRepeatedUint64()[0]); - $this->assertEquals(-44, $m->getRepeatedSint32()[0]); - $this->assertEquals(-45, $m->getRepeatedSint64()[0]); - $this->assertEquals(46, $m->getRepeatedFixed32()[0]); - $this->assertEquals(47, $m->getRepeatedFixed64()[0]); - $this->assertEquals(-46, $m->getRepeatedSfixed32()[0]); - $this->assertEquals(-47, $m->getRepeatedSfixed64()[0]); - $this->assertEquals(1.5, $m->getRepeatedFloat()[0]); - $this->assertEquals(1.6, $m->getRepeatedDouble()[0]); - $this->assertEquals(true, $m->getRepeatedBool()[0]); - $this->assertEquals('a', $m->getRepeatedString()[0]); - $this->assertEquals('b', $m->getRepeatedBytes()[0]); - $this->assertEquals(34, $m->getRepeatedMessage()[0]->GetA()); - - $this->assertEquals(-52, $m->getRepeatedInt32()[1]); - $this->assertEquals(52, $m->getRepeatedUint32()[1]); - $this->assertEquals(-53, $m->getRepeatedInt64()[1]); - $this->assertEquals(53, $m->getRepeatedUint64()[1]); - $this->assertEquals(-54, $m->getRepeatedSint32()[1]); - $this->assertEquals(-55, $m->getRepeatedSint64()[1]); - $this->assertEquals(56, $m->getRepeatedFixed32()[1]); - $this->assertEquals(57, $m->getRepeatedFixed64()[1]); - $this->assertEquals(-56, $m->getRepeatedSfixed32()[1]); - $this->assertEquals(-57, $m->getRepeatedSfixed64()[1]); - $this->assertEquals(2.5, $m->getRepeatedFloat()[1]); - $this->assertEquals(2.6, $m->getRepeatedDouble()[1]); - $this->assertEquals(false, $m->getRepeatedBool()[1]); - $this->assertEquals('c', $m->getRepeatedString()[1]); - $this->assertEquals('d', $m->getRepeatedBytes()[1]); - $this->assertEquals(35, $m->getRepeatedMessage()[1]->GetA()); - - if (PHP_INT_SIZE == 4) { - $this->assertEquals('-63', $m->getMapInt64Int64()['-63']); - $this->assertEquals('63', $m->getMapUint64Uint64()['63']); - $this->assertEquals('-65', $m->getMapSint64Sint64()['-65']); - $this->assertEquals('67', $m->getMapFixed64Fixed64()['67']); - $this->assertEquals('-69', $m->getMapSfixed64Sfixed64()['-69']); - } else { - $this->assertEquals(-63, $m->getMapInt64Int64()[-63]); - $this->assertEquals(63, $m->getMapUint64Uint64()[63]); - $this->assertEquals(-65, $m->getMapSint64Sint64()[-65]); - $this->assertEquals(67, $m->getMapFixed64Fixed64()[67]); - $this->assertEquals(-69, $m->getMapSfixed64Sfixed64()[-69]); - } - $this->assertEquals(-62, $m->getMapInt32Int32()[-62]); - $this->assertEquals(62, $m->getMapUint32Uint32()[62]); - $this->assertEquals(-64, $m->getMapSint32Sint32()[-64]); - $this->assertEquals(66, $m->getMapFixed32Fixed32()[66]); - $this->assertEquals(-68, $m->getMapSfixed32Sfixed32()[-68]); - $this->assertEquals(3.5, $m->getMapInt32Float()[1]); - $this->assertEquals(3.6, $m->getMapInt32Double()[1]); - $this->assertEquals(true , $m->getMapBoolBool()[true]); - $this->assertEquals('e', $m->getMapStringString()['e']); - $this->assertEquals('f', $m->getMapInt32Bytes()[1]); - $this->assertEquals(TestEnum::ONE, $m->getMapInt32Enum()[1]); - $this->assertEquals(36, $m->getMapInt32Message()[1]->GetA()); - } - - // Test message merged from setFields and setFields2. - public function expectFieldsMerged(TestMessage $m) - { - $this->assertSame(-144, $m->getOptionalSint32()); - $this->assertSame(146, $m->getOptionalFixed32()); - $this->assertSame(-146, $m->getOptionalSfixed32()); - $this->assertSame(11.5, $m->getOptionalFloat()); - $this->assertSame(11.6, $m->getOptionalDouble()); - $this->assertSame(true, $m->getOptionalBool()); - $this->assertSame('aa', $m->getOptionalString()); - $this->assertSame('bb', $m->getOptionalBytes()); - $this->assertSame(133, $m->getOptionalMessage()->getA()); - if (PHP_INT_SIZE == 4) { - $this->assertSame('-143', $m->getOptionalInt64()); - $this->assertSame('143', $m->getOptionalUint64()); - $this->assertSame('-145', $m->getOptionalSint64()); - $this->assertSame('147', $m->getOptionalFixed64()); - $this->assertSame('-147', $m->getOptionalSfixed64()); - } else { - $this->assertSame(-143, $m->getOptionalInt64()); - $this->assertSame(143, $m->getOptionalUint64()); - $this->assertSame(-145, $m->getOptionalSint64()); - $this->assertSame(147, $m->getOptionalFixed64()); - $this->assertSame(-147, $m->getOptionalSfixed64()); - } - - $this->assertEquals(-42, $m->getRepeatedInt32()[0]); - $this->assertEquals(42, $m->getRepeatedUint32()[0]); - $this->assertEquals(-43, $m->getRepeatedInt64()[0]); - $this->assertEquals(43, $m->getRepeatedUint64()[0]); - $this->assertEquals(-44, $m->getRepeatedSint32()[0]); - $this->assertEquals(-45, $m->getRepeatedSint64()[0]); - $this->assertEquals(46, $m->getRepeatedFixed32()[0]); - $this->assertEquals(47, $m->getRepeatedFixed64()[0]); - $this->assertEquals(-46, $m->getRepeatedSfixed32()[0]); - $this->assertEquals(-47, $m->getRepeatedSfixed64()[0]); - $this->assertEquals(1.5, $m->getRepeatedFloat()[0]); - $this->assertEquals(1.6, $m->getRepeatedDouble()[0]); - $this->assertEquals(true, $m->getRepeatedBool()[0]); - $this->assertEquals('a', $m->getRepeatedString()[0]); - $this->assertEquals('b', $m->getRepeatedBytes()[0]); - $this->assertEquals(TestEnum::ZERO, $m->getRepeatedEnum()[0]); - $this->assertEquals(34, $m->getRepeatedMessage()[0]->GetA()); - - $this->assertEquals(-52, $m->getRepeatedInt32()[1]); - $this->assertEquals(52, $m->getRepeatedUint32()[1]); - $this->assertEquals(-53, $m->getRepeatedInt64()[1]); - $this->assertEquals(53, $m->getRepeatedUint64()[1]); - $this->assertEquals(-54, $m->getRepeatedSint32()[1]); - $this->assertEquals(-55, $m->getRepeatedSint64()[1]); - $this->assertEquals(56, $m->getRepeatedFixed32()[1]); - $this->assertEquals(57, $m->getRepeatedFixed64()[1]); - $this->assertEquals(-56, $m->getRepeatedSfixed32()[1]); - $this->assertEquals(-57, $m->getRepeatedSfixed64()[1]); - $this->assertEquals(2.5, $m->getRepeatedFloat()[1]); - $this->assertEquals(2.6, $m->getRepeatedDouble()[1]); - $this->assertEquals(false, $m->getRepeatedBool()[1]); - $this->assertEquals('c', $m->getRepeatedString()[1]); - $this->assertEquals('d', $m->getRepeatedBytes()[1]); - $this->assertEquals(TestEnum::ONE, $m->getRepeatedEnum()[1]); - $this->assertEquals(35, $m->getRepeatedMessage()[1]->GetA()); - - $this->assertEquals(-142, $m->getRepeatedInt32()[2]); - $this->assertEquals(142, $m->getRepeatedUint32()[2]); - $this->assertEquals(-143, $m->getRepeatedInt64()[2]); - $this->assertEquals(143, $m->getRepeatedUint64()[2]); - $this->assertEquals(-144, $m->getRepeatedSint32()[2]); - $this->assertEquals(-145, $m->getRepeatedSint64()[2]); - $this->assertEquals(146, $m->getRepeatedFixed32()[2]); - $this->assertEquals(147, $m->getRepeatedFixed64()[2]); - $this->assertEquals(-146, $m->getRepeatedSfixed32()[2]); - $this->assertEquals(-147, $m->getRepeatedSfixed64()[2]); - $this->assertEquals(11.5, $m->getRepeatedFloat()[2]); - $this->assertEquals(11.6, $m->getRepeatedDouble()[2]); - $this->assertEquals(false, $m->getRepeatedBool()[2]); - $this->assertEquals('aa', $m->getRepeatedString()[2]); - $this->assertEquals('bb', $m->getRepeatedBytes()[2]); - $this->assertEquals(TestEnum::TWO, $m->getRepeatedEnum()[2]); - $this->assertEquals(134, $m->getRepeatedMessage()[2]->GetA()); - - if (PHP_INT_SIZE == 4) { - $this->assertEquals('-163', $m->getMapInt64Int64()['-63']); - $this->assertEquals('163', $m->getMapUint64Uint64()['63']); - $this->assertEquals('-165', $m->getMapSint64Sint64()['-65']); - $this->assertEquals('167', $m->getMapFixed64Fixed64()['67']); - $this->assertEquals('-169', $m->getMapSfixed64Sfixed64()['-69']); - } else { - $this->assertEquals(-163, $m->getMapInt64Int64()[-63]); - $this->assertEquals(163, $m->getMapUint64Uint64()[63]); - $this->assertEquals(-165, $m->getMapSint64Sint64()[-65]); - $this->assertEquals(167, $m->getMapFixed64Fixed64()[67]); - $this->assertEquals(-169, $m->getMapSfixed64Sfixed64()[-69]); - } - $this->assertEquals(-162, $m->getMapInt32Int32()[-62]); - $this->assertEquals(162, $m->getMapUint32Uint32()[62]); - $this->assertEquals(-164, $m->getMapSint32Sint32()[-64]); - $this->assertEquals(166, $m->getMapFixed32Fixed32()[66]); - $this->assertEquals(-168, $m->getMapSfixed32Sfixed32()[-68]); - $this->assertEquals(13.5, $m->getMapInt32Float()[1]); - $this->assertEquals(13.6, $m->getMapInt32Double()[1]); - $this->assertEquals(false , $m->getMapBoolBool()[true]); - $this->assertEquals('ee', $m->getMapStringString()['e']); - $this->assertEquals('ff', $m->getMapInt32Bytes()[1]); - $this->assertEquals(TestEnum::TWO, $m->getMapInt32Enum()[1]); - $this->assertEquals(136, $m->getMapInt32Message()[1]->GetA()); - - if (PHP_INT_SIZE == 4) { - $this->assertEquals('-163', $m->getMapInt64Int64()['-163']); - $this->assertEquals('163', $m->getMapUint64Uint64()['163']); - $this->assertEquals('-165', $m->getMapSint64Sint64()['-165']); - $this->assertEquals('167', $m->getMapFixed64Fixed64()['167']); - $this->assertEquals('-169', $m->getMapSfixed64Sfixed64()['-169']); - } else { - $this->assertEquals(-163, $m->getMapInt64Int64()[-163]); - $this->assertEquals(163, $m->getMapUint64Uint64()[163]); - $this->assertEquals(-165, $m->getMapSint64Sint64()[-165]); - $this->assertEquals(167, $m->getMapFixed64Fixed64()[167]); - $this->assertEquals(-169, $m->getMapSfixed64Sfixed64()[-169]); - } - $this->assertEquals(-162, $m->getMapInt32Int32()[-162]); - $this->assertEquals(162, $m->getMapUint32Uint32()[162]); - $this->assertEquals(-164, $m->getMapSint32Sint32()[-164]); - $this->assertEquals(166, $m->getMapFixed32Fixed32()[166]); - $this->assertEquals(-168, $m->getMapSfixed32Sfixed32()[-168]); - $this->assertEquals(13.5, $m->getMapInt32Float()[2]); - $this->assertEquals(13.6, $m->getMapInt32Double()[2]); - $this->assertEquals(false , $m->getMapBoolBool()[false]); - $this->assertEquals('ee', $m->getMapStringString()['ee']); - $this->assertEquals('ff', $m->getMapInt32Bytes()[2]); - $this->assertEquals(TestEnum::TWO, $m->getMapInt32Enum()[2]); - $this->assertEquals(136, $m->getMapInt32Message()[2]->GetA()); - } - - public function expectEmptyFields(TestMessage $m) - { - $this->assertSame(0, $m->getOptionalInt32()); - $this->assertSame(0, $m->getOptionalUint32()); - $this->assertSame(0, $m->getOptionalSint32()); - $this->assertSame(0, $m->getOptionalFixed32()); - $this->assertSame(0, $m->getOptionalSfixed32()); - $this->assertSame(0.0, $m->getOptionalFloat()); - $this->assertSame(0.0, $m->getOptionalDouble()); - $this->assertSame(false, $m->getOptionalBool()); - $this->assertSame('', $m->getOptionalString()); - $this->assertSame('', $m->getOptionalBytes()); - $this->assertSame(0, $m->getOptionalEnum()); - $this->assertNull($m->getOptionalMessage()); - $this->assertNull($m->getOptionalIncludedMessage()); - $this->assertNull($m->getRecursive()); - if (PHP_INT_SIZE == 4) { - $this->assertSame("0", $m->getOptionalInt64()); - $this->assertSame("0", $m->getOptionalUint64()); - $this->assertSame("0", $m->getOptionalSint64()); - $this->assertSame("0", $m->getOptionalFixed64()); - $this->assertSame("0", $m->getOptionalSfixed64()); - } else { - $this->assertSame(0, $m->getOptionalInt64()); - $this->assertSame(0, $m->getOptionalUint64()); - $this->assertSame(0, $m->getOptionalSint64()); - $this->assertSame(0, $m->getOptionalFixed64()); - $this->assertSame(0, $m->getOptionalSfixed64()); - } - - $this->assertEquals(0, count($m->getRepeatedInt32())); - $this->assertEquals(0, count($m->getRepeatedUint32())); - $this->assertEquals(0, count($m->getRepeatedInt64())); - $this->assertEquals(0, count($m->getRepeatedUint64())); - $this->assertEquals(0, count($m->getRepeatedSint32())); - $this->assertEquals(0, count($m->getRepeatedSint64())); - $this->assertEquals(0, count($m->getRepeatedFixed32())); - $this->assertEquals(0, count($m->getRepeatedFixed64())); - $this->assertEquals(0, count($m->getRepeatedSfixed32())); - $this->assertEquals(0, count($m->getRepeatedSfixed64())); - $this->assertEquals(0, count($m->getRepeatedFloat())); - $this->assertEquals(0, count($m->getRepeatedDouble())); - $this->assertEquals(0, count($m->getRepeatedBool())); - $this->assertEquals(0, count($m->getRepeatedString())); - $this->assertEquals(0, count($m->getRepeatedBytes())); - $this->assertEquals(0, count($m->getRepeatedEnum())); - $this->assertEquals(0, count($m->getRepeatedMessage())); - $this->assertEquals(0, count($m->getRepeatedRecursive())); - - $this->assertSame("", $m->getMyOneof()); - $this->assertSame(0, $m->getOneofInt32()); - $this->assertSame(0, $m->getOneofUint32()); - $this->assertSame(0, $m->getOneofSint32()); - $this->assertSame(0, $m->getOneofFixed32()); - $this->assertSame(0, $m->getOneofSfixed32()); - $this->assertSame(0.0, $m->getOneofFloat()); - $this->assertSame(0.0, $m->getOneofDouble()); - $this->assertSame(false, $m->getOneofBool()); - $this->assertSame('', $m->getOneofString()); - $this->assertSame('', $m->getOneofBytes()); - $this->assertSame(0, $m->getOneofEnum()); - $this->assertNull($m->getOptionalMessage()); - if (PHP_INT_SIZE == 4) { - $this->assertSame("0", $m->getOneofInt64()); - $this->assertSame("0", $m->getOneofUint64()); - $this->assertSame("0", $m->getOneofSint64()); - $this->assertSame("0", $m->getOneofFixed64()); - $this->assertSame("0", $m->getOneofSfixed64()); - } else { - $this->assertSame(0, $m->getOneofInt64()); - $this->assertSame(0, $m->getOneofUint64()); - $this->assertSame(0, $m->getOneofSint64()); - $this->assertSame(0, $m->getOneofFixed64()); - $this->assertSame(0, $m->getOneofSfixed64()); - } - - $this->assertEquals(0, count($m->getMapInt64Int64())); - $this->assertEquals(0, count($m->getMapUint64Uint64())); - $this->assertEquals(0, count($m->getMapSint64Sint64())); - $this->assertEquals(0, count($m->getMapFixed64Fixed64())); - $this->assertEquals(0, count($m->getMapInt32Int32())); - $this->assertEquals(0, count($m->getMapUint32Uint32())); - $this->assertEquals(0, count($m->getMapSint32Sint32())); - $this->assertEquals(0, count($m->getMapFixed32Fixed32())); - $this->assertEquals(0, count($m->getMapSfixed32Sfixed32())); - $this->assertEquals(0, count($m->getMapSfixed64Sfixed64())); - $this->assertEquals(0, count($m->getMapInt32Float())); - $this->assertEquals(0, count($m->getMapInt32Double())); - $this->assertEquals(0, count($m->getMapBoolBool())); - $this->assertEquals(0, count($m->getMapStringString())); - $this->assertEquals(0, count($m->getMapInt32Bytes())); - $this->assertEquals(0, count($m->getMapInt32Enum())); - $this->assertEquals(0, count($m->getMapInt32Message())); - $this->assertEquals(0, count($m->getMapRecursive())); - } - - // This test is to avoid the warning of no test by php unit. - public function testNone() - { - } -} diff --git a/third_party/protobuf/3.4.0/php/tests/test_util.php b/third_party/protobuf/3.4.0/php/tests/test_util.php deleted file mode 100644 index c8afdd3e79..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/test_util.php +++ /dev/null @@ -1,547 +0,0 @@ -<?php - -use Foo\TestEnum; -use Foo\TestMessage; -use Foo\TestMessage_Sub; -use Foo\TestPackedMessage; -use Foo\TestUnpackedMessage; - -define('MAX_FLOAT_DIFF', 0.000001); - -if (PHP_INT_SIZE == 8) { - define('MAX_INT_STRING', '9223372036854775807'); - define('MAX_INT_UPPER_STRING', '9223372036854775808'); -} else { - define('MAX_INT_STRING', '2147483647'); - define('MAX_INT_UPPER_STRING', '2147483648'); -} - -define('MAX_INT32', 2147483647); -define('MAX_INT32_FLOAT', 2147483647.0); -define('MAX_INT32_STRING', '2147483647'); - -define('MIN_INT32', (int)-2147483648); -define('MIN_INT32_FLOAT', -2147483648.0); -define('MIN_INT32_STRING', '-2147483648'); - -define('MAX_UINT32', 4294967295); -define('MAX_UINT32_FLOAT', 4294967295.0); -define('MAX_UINT32_STRING', '4294967295'); - -define('MIN_UINT32', (int)-2147483648); -define('MIN_UINT32_FLOAT', -2147483648.0); -define('MIN_UINT32_STRING', '-2147483648'); - -define('MAX_INT64_STRING', '9223372036854775807'); -define('MIN_INT64_STRING', '-9223372036854775808'); -define('MAX_UINT64_STRING', '-9223372036854775808'); - -if (PHP_INT_SIZE === 8) { - define('MAX_INT64', (int)9223372036854775807); - define('MIN_INT64', (int)-9223372036854775808); - define('MAX_UINT64', (int)-9223372036854775808); -} else { - define('MAX_INT64', MAX_INT64_STRING); - define('MIN_INT64', MIN_INT64_STRING); - define('MAX_UINT64', MAX_UINT64_STRING); -} - -class TestUtil -{ - - public static function setTestMessage(TestMessage $m) - { - $m->setOptionalInt32(-42); - $m->setOptionalInt64(-43); - $m->setOptionalUint32(42); - $m->setOptionalUint64(43); - $m->setOptionalSint32(-44); - $m->setOptionalSint64(-45); - $m->setOptionalFixed32(46); - $m->setOptionalFixed64(47); - $m->setOptionalSfixed32(-46); - $m->setOptionalSfixed64(-47); - $m->setOptionalFloat(1.5); - $m->setOptionalDouble(1.6); - $m->setOptionalBool(true); - $m->setOptionalString('a'); - $m->setOptionalBytes('b'); - $m->setOptionalEnum(TestEnum::ONE); - $sub = new TestMessage_Sub(); - $m->setOptionalMessage($sub); - $m->getOptionalMessage()->SetA(33); - - self::appendHelper($m, 'RepeatedInt32', -42); - self::appendHelper($m, 'RepeatedInt64', -43); - self::appendHelper($m, 'RepeatedUint32', 42); - self::appendHelper($m, 'RepeatedUint64', 43); - self::appendHelper($m, 'RepeatedSint32', -44); - self::appendHelper($m, 'RepeatedSint64', -45); - self::appendHelper($m, 'RepeatedFixed32', 46); - self::appendHelper($m, 'RepeatedFixed64', 47); - self::appendHelper($m, 'RepeatedSfixed32', -46); - self::appendHelper($m, 'RepeatedSfixed64', -47); - self::appendHelper($m, 'RepeatedFloat', 1.5); - self::appendHelper($m, 'RepeatedDouble', 1.6); - self::appendHelper($m, 'RepeatedBool', true); - self::appendHelper($m, 'RepeatedString', 'a'); - self::appendHelper($m, 'RepeatedBytes', 'b'); - self::appendHelper($m, 'RepeatedEnum', TestEnum::ZERO); - self::appendHelper($m, 'RepeatedMessage', new TestMessage_Sub()); - $m->getRepeatedMessage()[0]->setA(34); - - self::appendHelper($m, 'RepeatedInt32', -52); - self::appendHelper($m, 'RepeatedInt64', -53); - self::appendHelper($m, 'RepeatedUint32', 52); - self::appendHelper($m, 'RepeatedUint64', 53); - self::appendHelper($m, 'RepeatedSint32', -54); - self::appendHelper($m, 'RepeatedSint64', -55); - self::appendHelper($m, 'RepeatedFixed32', 56); - self::appendHelper($m, 'RepeatedFixed64', 57); - self::appendHelper($m, 'RepeatedSfixed32', -56); - self::appendHelper($m, 'RepeatedSfixed64', -57); - self::appendHelper($m, 'RepeatedFloat', 2.5); - self::appendHelper($m, 'RepeatedDouble', 2.6); - self::appendHelper($m, 'RepeatedBool', false); - self::appendHelper($m, 'RepeatedString', 'c'); - self::appendHelper($m, 'RepeatedBytes', 'd'); - self::appendHelper($m, 'RepeatedEnum', TestEnum::ONE); - self::appendHelper($m, 'RepeatedMessage', new TestMessage_Sub()); - $m->getRepeatedMessage()[1]->SetA(35); - - self::kvUpdateHelper($m, 'MapInt32Int32', -62, -62); - self::kvUpdateHelper($m, 'MapInt64Int64', -63, -63); - self::kvUpdateHelper($m, 'MapUint32Uint32', 62, 62); - self::kvUpdateHelper($m, 'MapUint64Uint64', 63, 63); - self::kvUpdateHelper($m, 'MapSint32Sint32', -64, -64); - self::kvUpdateHelper($m, 'MapSint64Sint64', -65, -65); - self::kvUpdateHelper($m, 'MapFixed32Fixed32', 66, 66); - self::kvUpdateHelper($m, 'MapFixed64Fixed64', 67, 67); - self::kvUpdateHelper($m, 'MapSfixed32Sfixed32', -68, -68); - self::kvUpdateHelper($m, 'MapSfixed64Sfixed64', -69, -69); - self::kvUpdateHelper($m, 'MapInt32Float', 1, 3.5); - self::kvUpdateHelper($m, 'MapInt32Double', 1, 3.6); - self::kvUpdateHelper($m, 'MapBoolBool', true, true); - self::kvUpdateHelper($m, 'MapStringString', 'e', 'e'); - self::kvUpdateHelper($m, 'MapInt32Bytes', 1, 'f'); - self::kvUpdateHelper($m, 'MapInt32Enum', 1, TestEnum::ONE); - self::kvUpdateHelper($m, 'MapInt32Message', 1, new TestMessage_Sub()); - $m->getMapInt32Message()[1]->SetA(36); - } - - public static function setTestMessage2(TestMessage $m) - { - $sub = new TestMessage_Sub(); - - $m->setOptionalInt32(-142); - $m->setOptionalInt64(-143); - $m->setOptionalUint32(142); - $m->setOptionalUint64(143); - $m->setOptionalSint32(-144); - $m->setOptionalSint64(-145); - $m->setOptionalFixed32(146); - $m->setOptionalFixed64(147); - $m->setOptionalSfixed32(-146); - $m->setOptionalSfixed64(-147); - $m->setOptionalFloat(11.5); - $m->setOptionalDouble(11.6); - $m->setOptionalBool(true); - $m->setOptionalString('aa'); - $m->setOptionalBytes('bb'); - $m->setOptionalEnum(TestEnum::TWO); - $m->setOptionalMessage($sub); - $m->getOptionalMessage()->SetA(133); - - self::appendHelper($m, 'RepeatedInt32', -142); - self::appendHelper($m, 'RepeatedInt64', -143); - self::appendHelper($m, 'RepeatedUint32', 142); - self::appendHelper($m, 'RepeatedUint64', 143); - self::appendHelper($m, 'RepeatedSint32', -144); - self::appendHelper($m, 'RepeatedSint64', -145); - self::appendHelper($m, 'RepeatedFixed32', 146); - self::appendHelper($m, 'RepeatedFixed64', 147); - self::appendHelper($m, 'RepeatedSfixed32', -146); - self::appendHelper($m, 'RepeatedSfixed64', -147); - self::appendHelper($m, 'RepeatedFloat', 11.5); - self::appendHelper($m, 'RepeatedDouble', 11.6); - self::appendHelper($m, 'RepeatedBool', false); - self::appendHelper($m, 'RepeatedString', 'aa'); - self::appendHelper($m, 'RepeatedBytes', 'bb'); - self::appendHelper($m, 'RepeatedEnum', TestEnum::TWO); - self::appendHelper($m, 'RepeatedMessage', new TestMessage_Sub()); - $m->getRepeatedMessage()[0]->setA(134); - - self::kvUpdateHelper($m, 'MapInt32Int32', -62, -162); - self::kvUpdateHelper($m, 'MapInt64Int64', -63, -163); - self::kvUpdateHelper($m, 'MapUint32Uint32', 62, 162); - self::kvUpdateHelper($m, 'MapUint64Uint64', 63, 163); - self::kvUpdateHelper($m, 'MapSint32Sint32', -64, -164); - self::kvUpdateHelper($m, 'MapSint64Sint64', -65, -165); - self::kvUpdateHelper($m, 'MapFixed32Fixed32', 66, 166); - self::kvUpdateHelper($m, 'MapFixed64Fixed64', 67, 167); - self::kvUpdateHelper($m, 'MapSfixed32Sfixed32', -68, -168); - self::kvUpdateHelper($m, 'MapSfixed64Sfixed64', -69, -169); - self::kvUpdateHelper($m, 'MapInt32Float', 1, 13.5); - self::kvUpdateHelper($m, 'MapInt32Double', 1, 13.6); - self::kvUpdateHelper($m, 'MapBoolBool', true, false); - self::kvUpdateHelper($m, 'MapStringString', 'e', 'ee'); - self::kvUpdateHelper($m, 'MapInt32Bytes', 1, 'ff'); - self::kvUpdateHelper($m, 'MapInt32Enum', 1, TestEnum::TWO); - self::kvUpdateHelper($m, 'MapInt32Message', 1, new TestMessage_Sub()); - $m->getMapInt32Message()[1]->SetA(136); - - self::kvUpdateHelper($m, 'MapInt32Int32', -162, -162); - self::kvUpdateHelper($m, 'MapInt64Int64', -163, -163); - self::kvUpdateHelper($m, 'MapUint32Uint32', 162, 162); - self::kvUpdateHelper($m, 'MapUint64Uint64', 163, 163); - self::kvUpdateHelper($m, 'MapSint32Sint32', -164, -164); - self::kvUpdateHelper($m, 'MapSint64Sint64', -165, -165); - self::kvUpdateHelper($m, 'MapFixed32Fixed32', 166, 166); - self::kvUpdateHelper($m, 'MapFixed64Fixed64', 167, 167); - self::kvUpdateHelper($m, 'MapSfixed32Sfixed32', -168, -168); - self::kvUpdateHelper($m, 'MapSfixed64Sfixed64', -169, -169); - self::kvUpdateHelper($m, 'MapInt32Float', 2, 13.5); - self::kvUpdateHelper($m, 'MapInt32Double', 2, 13.6); - self::kvUpdateHelper($m, 'MapBoolBool', false, false); - self::kvUpdateHelper($m, 'MapStringString', 'ee', 'ee'); - self::kvUpdateHelper($m, 'MapInt32Bytes', 2, 'ff'); - self::kvUpdateHelper($m, 'MapInt32Enum', 2, TestEnum::TWO); - self::kvUpdateHelper($m, 'MapInt32Message', 2, new TestMessage_Sub()); - $m->getMapInt32Message()[2]->SetA(136); - } - - public static function assertTestMessage(TestMessage $m) - { - if (PHP_INT_SIZE == 4) { - assert('-43' === $m->getOptionalInt64()); - assert('43' === $m->getOptionalUint64()); - assert('-45' === $m->getOptionalSint64()); - assert('47' === $m->getOptionalFixed64()); - assert('-47' === $m->getOptionalSfixed64()); - } else { - assert(-43 === $m->getOptionalInt64()); - assert(43 === $m->getOptionalUint64()); - assert(-45 === $m->getOptionalSint64()); - assert(47 === $m->getOptionalFixed64()); - assert(-47 === $m->getOptionalSfixed64()); - } - assert(-42 === $m->getOptionalInt32()); - assert(42 === $m->getOptionalUint32()); - assert(-44 === $m->getOptionalSint32()); - assert(46 === $m->getOptionalFixed32()); - assert(-46 === $m->getOptionalSfixed32()); - assert(1.5 === $m->getOptionalFloat()); - assert(1.6 === $m->getOptionalDouble()); - assert(true=== $m->getOptionalBool()); - assert('a' === $m->getOptionalString()); - assert('b' === $m->getOptionalBytes()); - assert(TestEnum::ONE === $m->getOptionalEnum()); - assert(33 === $m->getOptionalMessage()->getA()); - - if (PHP_INT_SIZE == 4) { - assert('-43' === $m->getRepeatedInt64()[0]); - assert('43' === $m->getRepeatedUint64()[0]); - assert('-45' === $m->getRepeatedSint64()[0]); - assert('47' === $m->getRepeatedFixed64()[0]); - assert('-47' === $m->getRepeatedSfixed64()[0]); - } else { - assert(-43 === $m->getRepeatedInt64()[0]); - assert(43 === $m->getRepeatedUint64()[0]); - assert(-45 === $m->getRepeatedSint64()[0]); - assert(47 === $m->getRepeatedFixed64()[0]); - assert(-47 === $m->getRepeatedSfixed64()[0]); - } - assert(-42 === $m->getRepeatedInt32()[0]); - assert(42 === $m->getRepeatedUint32()[0]); - assert(-44 === $m->getRepeatedSint32()[0]); - assert(46 === $m->getRepeatedFixed32()[0]); - assert(-46 === $m->getRepeatedSfixed32()[0]); - assert(1.5 === $m->getRepeatedFloat()[0]); - assert(1.6 === $m->getRepeatedDouble()[0]); - assert(true=== $m->getRepeatedBool()[0]); - assert('a' === $m->getRepeatedString()[0]); - assert('b' === $m->getRepeatedBytes()[0]); - assert(TestEnum::ZERO === $m->getRepeatedEnum()[0]); - assert(34 === $m->getRepeatedMessage()[0]->getA()); - - if (PHP_INT_SIZE == 4) { - assert('-53' === $m->getRepeatedInt64()[1]); - assert('53' === $m->getRepeatedUint64()[1]); - assert('-55' === $m->getRepeatedSint64()[1]); - assert('57' === $m->getRepeatedFixed64()[1]); - assert('-57' === $m->getRepeatedSfixed64()[1]); - } else { - assert(-53 === $m->getRepeatedInt64()[1]); - assert(53 === $m->getRepeatedUint64()[1]); - assert(-55 === $m->getRepeatedSint64()[1]); - assert(57 === $m->getRepeatedFixed64()[1]); - assert(-57 === $m->getRepeatedSfixed64()[1]); - } - assert(-52 === $m->getRepeatedInt32()[1]); - assert(52 === $m->getRepeatedUint32()[1]); - assert(-54 === $m->getRepeatedSint32()[1]); - assert(56 === $m->getRepeatedFixed32()[1]); - assert(-56 === $m->getRepeatedSfixed32()[1]); - assert(2.5 === $m->getRepeatedFloat()[1]); - assert(2.6 === $m->getRepeatedDouble()[1]); - assert(false === $m->getRepeatedBool()[1]); - assert('c' === $m->getRepeatedString()[1]); - assert('d' === $m->getRepeatedBytes()[1]); - assert(TestEnum::ONE === $m->getRepeatedEnum()[1]); - assert(35 === $m->getRepeatedMessage()[1]->getA()); - - if (PHP_INT_SIZE == 4) { - assert('-63' === $m->getMapInt64Int64()['-63']); - assert('63' === $m->getMapUint64Uint64()['63']); - assert('-65' === $m->getMapSint64Sint64()['-65']); - assert('67' === $m->getMapFixed64Fixed64()['67']); - assert('-69' === $m->getMapSfixed64Sfixed64()['-69']); - } else { - assert(-63 === $m->getMapInt64Int64()[-63]); - assert(63 === $m->getMapUint64Uint64()[63]); - assert(-65 === $m->getMapSint64Sint64()[-65]); - assert(67 === $m->getMapFixed64Fixed64()[67]); - assert(-69 === $m->getMapSfixed64Sfixed64()[-69]); - } - assert(-62 === $m->getMapInt32Int32()[-62]); - assert(62 === $m->getMapUint32Uint32()[62]); - assert(-64 === $m->getMapSint32Sint32()[-64]); - assert(66 === $m->getMapFixed32Fixed32()[66]); - assert(-68 === $m->getMapSfixed32Sfixed32()[-68]); - assert(3.5 === $m->getMapInt32Float()[1]); - assert(3.6 === $m->getMapInt32Double()[1]); - assert(true === $m->getMapBoolBool()[true]); - assert('e' === $m->getMapStringString()['e']); - assert('f' === $m->getMapInt32Bytes()[1]); - assert(TestEnum::ONE === $m->getMapInt32Enum()[1]); - assert(36 === $m->getMapInt32Message()[1]->GetA()); - } - - public static function getGoldenTestMessage() - { - return hex2bin( - "08D6FFFFFFFFFFFFFFFF01" . - "10D5FFFFFFFFFFFFFFFF01" . - "182A" . - "202B" . - "2857" . - "3059" . - "3D2E000000" . - "412F00000000000000" . - "4DD2FFFFFF" . - "51D1FFFFFFFFFFFFFF" . - "5D0000C03F" . - "619A9999999999F93F" . - "6801" . - "720161" . - "7A0162" . - "800101" . - "8A01020821" . - - "F801D6FFFFFFFFFFFFFFFF01" . - "F801CCFFFFFFFFFFFFFFFF01" . - "8002D5FFFFFFFFFFFFFFFF01" . - "8002CBFFFFFFFFFFFFFFFF01" . - "88022A" . - "880234" . - "90022B" . - "900235" . - "980257" . - "98026B" . - "A00259" . - "A0026D" . - "AD022E000000" . - "AD0238000000" . - "B1022F00000000000000" . - "B1023900000000000000" . - "BD02D2FFFFFF" . - "BD02C8FFFFFF" . - "C102D1FFFFFFFFFFFFFF" . - "C102C7FFFFFFFFFFFFFF" . - "CD020000C03F" . - "CD0200002040" . - "D1029A9999999999F93F" . - "D102CDCCCCCCCCCC0440" . - "D80201" . - "D80200" . - "E2020161" . - "E2020163" . - "EA020162" . - "EA020164" . - "F00200" . - "F00201" . - "FA02020822" . - "FA02020823" . - - "BA041608C2FFFFFFFFFFFFFFFF0110C2FFFFFFFFFFFFFFFF01" . - "C2041608C1FFFFFFFFFFFFFFFF0110C1FFFFFFFFFFFFFFFF01" . - "CA0404083E103E" . - "D20404083F103F" . - "DA0404087f107F" . - "E20406088101108101" . - "EA040A0D420000001542000000" . - "F20412094300000000000000114300000000000000" . - "FA040A0DBCFFFFFF15BCFFFFFF" . - "82051209BBFFFFFFFFFFFFFF11BBFFFFFFFFFFFFFF" . - "8A050708011500006040" . - "92050B080111CDCCCCCCCCCC0C40" . - "9A050408011001" . - "A205060a0165120165" . - "AA05050801120166" . - "B2050408011001" . - "Ba0506080112020824" - ); - } - - public static function setTestPackedMessage($m) - { - self::appendHelper($m, 'RepeatedInt32', -42); - self::appendHelper($m, 'RepeatedInt32', -52); - self::appendHelper($m, 'RepeatedInt64', -43); - self::appendHelper($m, 'RepeatedInt64', -53); - self::appendHelper($m, 'RepeatedUint32', 42); - self::appendHelper($m, 'RepeatedUint32', 52); - self::appendHelper($m, 'RepeatedUint64', 43); - self::appendHelper($m, 'RepeatedUint64', 53); - self::appendHelper($m, 'RepeatedSint32', -44); - self::appendHelper($m, 'RepeatedSint32', -54); - self::appendHelper($m, 'RepeatedSint64', -45); - self::appendHelper($m, 'RepeatedSint64', -55); - self::appendHelper($m, 'RepeatedFixed32', 46); - self::appendHelper($m, 'RepeatedFixed32', 56); - self::appendHelper($m, 'RepeatedFixed64', 47); - self::appendHelper($m, 'RepeatedFixed64', 57); - self::appendHelper($m, 'RepeatedSfixed32', -46); - self::appendHelper($m, 'RepeatedSfixed32', -56); - self::appendHelper($m, 'RepeatedSfixed64', -47); - self::appendHelper($m, 'RepeatedSfixed64', -57); - self::appendHelper($m, 'RepeatedFloat', 1.5); - self::appendHelper($m, 'RepeatedFloat', 2.5); - self::appendHelper($m, 'RepeatedDouble', 1.6); - self::appendHelper($m, 'RepeatedDouble', 2.6); - self::appendHelper($m, 'RepeatedBool', true); - self::appendHelper($m, 'RepeatedBool', false); - self::appendHelper($m, 'RepeatedEnum', TestEnum::ONE); - self::appendHelper($m, 'RepeatedEnum', TestEnum::ZERO); - } - - public static function assertTestPackedMessage($m) - { - assert(2 === count($m->getRepeatedInt32())); - assert(2 === count($m->getRepeatedInt64())); - assert(2 === count($m->getRepeatedUint32())); - assert(2 === count($m->getRepeatedUint64())); - assert(2 === count($m->getRepeatedSint32())); - assert(2 === count($m->getRepeatedSint64())); - assert(2 === count($m->getRepeatedFixed32())); - assert(2 === count($m->getRepeatedFixed64())); - assert(2 === count($m->getRepeatedSfixed32())); - assert(2 === count($m->getRepeatedSfixed64())); - assert(2 === count($m->getRepeatedFloat())); - assert(2 === count($m->getRepeatedDouble())); - assert(2 === count($m->getRepeatedBool())); - assert(2 === count($m->getRepeatedEnum())); - - assert(-42 === $m->getRepeatedInt32()[0]); - assert(-52 === $m->getRepeatedInt32()[1]); - assert(42 === $m->getRepeatedUint32()[0]); - assert(52 === $m->getRepeatedUint32()[1]); - assert(-44 === $m->getRepeatedSint32()[0]); - assert(-54 === $m->getRepeatedSint32()[1]); - assert(46 === $m->getRepeatedFixed32()[0]); - assert(56 === $m->getRepeatedFixed32()[1]); - assert(-46 === $m->getRepeatedSfixed32()[0]); - assert(-56 === $m->getRepeatedSfixed32()[1]); - assert(1.5 === $m->getRepeatedFloat()[0]); - assert(2.5 === $m->getRepeatedFloat()[1]); - assert(1.6 === $m->getRepeatedDouble()[0]); - assert(2.6 === $m->getRepeatedDouble()[1]); - assert(true === $m->getRepeatedBool()[0]); - assert(false === $m->getRepeatedBool()[1]); - assert(TestEnum::ONE === $m->getRepeatedEnum()[0]); - assert(TestEnum::ZERO === $m->getRepeatedEnum()[1]); - if (PHP_INT_SIZE == 4) { - assert('-43' === $m->getRepeatedInt64()[0]); - assert('-53' === $m->getRepeatedInt64()[1]); - assert('43' === $m->getRepeatedUint64()[0]); - assert('53' === $m->getRepeatedUint64()[1]); - assert('-45' === $m->getRepeatedSint64()[0]); - assert('-55' === $m->getRepeatedSint64()[1]); - assert('47' === $m->getRepeatedFixed64()[0]); - assert('57' === $m->getRepeatedFixed64()[1]); - assert('-47' === $m->getRepeatedSfixed64()[0]); - assert('-57' === $m->getRepeatedSfixed64()[1]); - } else { - assert(-43 === $m->getRepeatedInt64()[0]); - assert(-53 === $m->getRepeatedInt64()[1]); - assert(43 === $m->getRepeatedUint64()[0]); - assert(53 === $m->getRepeatedUint64()[1]); - assert(-45 === $m->getRepeatedSint64()[0]); - assert(-55 === $m->getRepeatedSint64()[1]); - assert(47 === $m->getRepeatedFixed64()[0]); - assert(57 === $m->getRepeatedFixed64()[1]); - assert(-47 === $m->getRepeatedSfixed64()[0]); - assert(-57 === $m->getRepeatedSfixed64()[1]); - } - } - - public static function getGoldenTestPackedMessage() - { - return hex2bin( - "D20514D6FFFFFFFFFFFFFFFF01CCFFFFFFFFFFFFFFFF01" . - "DA0514D5FFFFFFFFFFFFFFFF01CBFFFFFFFFFFFFFFFF01" . - "E205022A34" . - "EA05022B35" . - "F20502576B" . - "FA0502596D" . - "8206082E00000038000000" . - "8A06102F000000000000003900000000000000" . - "920608D2FFFFFFC8FFFFFF" . - "9A0610D1FFFFFFFFFFFFFFC7FFFFFFFFFFFFFF" . - "A206080000C03F00002040" . - "AA06109A9999999999F93FCDCCCCCCCCCC0440" . - "B206020100" . - "BA06020100" - ); - } - - public static function getGoldenTestUnpackedMessage() - { - return hex2bin( - "D005D6FFFFFFFFFFFFFFFF01D005CCFFFFFFFFFFFFFFFF01" . - "D805D5FFFFFFFFFFFFFFFF01D805CBFFFFFFFFFFFFFFFF01" . - "E0052AE00534" . - "E8052BE80535" . - "F00557F0056B" . - "F80559F8056D" . - "85062E000000850638000000" . - "89062F0000000000000089063900000000000000" . - "9506D2FFFFFF9506C8FFFFFF" . - "9906D1FFFFFFFFFFFFFF9906C7FFFFFFFFFFFFFF" . - "A5060000C03FA50600002040" . - "A9069A9999999999F93FA906CDCCCCCCCCCC0440" . - "B00601B00600" . - "B80601B80600" - ); - } - - private static function appendHelper($obj, $func_suffix, $value) - { - $getter_function = 'get'.$func_suffix; - $setter_function = 'set'.$func_suffix; - - $arr = $obj->$getter_function(); - $arr[] = $value; - $obj->$setter_function($arr); - } - - private static function kvUpdateHelper($obj, $func_suffix, $key, $value) - { - $getter_function = 'get'.$func_suffix; - $setter_function = 'set'.$func_suffix; - - $arr = $obj->$getter_function(); - $arr[$key] = $value; - $obj->$setter_function($arr); - } -} diff --git a/third_party/protobuf/3.4.0/php/tests/undefined_test.php b/third_party/protobuf/3.4.0/php/tests/undefined_test.php deleted file mode 100644 index dc6b708618..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/undefined_test.php +++ /dev/null @@ -1,920 +0,0 @@ -<?php - -require_once('test_util.php'); - -use Google\Protobuf\Internal\RepeatedField; -use Google\Protobuf\Internal\GPBType; -use Foo\TestMessage; -use Foo\TestMessage_Sub; - -class UndefinedTest extends PHPUnit_Framework_TestCase -{ - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32AppendStringFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr[] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32SetStringFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr[] = 0; - $arr[0] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32AppendMessageFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr[] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32SetMessageFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr[] = 0; - $arr[0] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32AppendStringFail() - { - $arr = new RepeatedField(GPBType::UINT32); - $arr[] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32SetStringFail() - { - $arr = new RepeatedField(GPBType::UINT32); - $arr[] = 0; - $arr[0] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32AppendMessageFail() - { - $arr = new RepeatedField(GPBType::UINT32); - $arr[] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32SetMessageFail() - { - $arr = new RepeatedField(GPBType::UINT32); - $arr[] = 0; - $arr[0] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64AppendStringFail() - { - $arr = new RepeatedField(GPBType::INT64); - $arr[] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64SetStringFail() - { - $arr = new RepeatedField(GPBType::INT64); - $arr[] = 0; - $arr[0] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64AppendMessageFail() - { - $arr = new RepeatedField(GPBType::INT64); - $arr[] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64SetMessageFail() - { - $arr = new RepeatedField(GPBType::INT64); - $arr[] = 0; - $arr[0] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64AppendStringFail() - { - $arr = new RepeatedField(GPBType::UINT64); - $arr[] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64SetStringFail() - { - $arr = new RepeatedField(GPBType::UINT64); - $arr[] = 0; - $arr[0] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64AppendMessageFail() - { - $arr = new RepeatedField(GPBType::UINT64); - $arr[] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64SetMessageFail() - { - $arr = new RepeatedField(GPBType::UINT64); - $arr[] = 0; - $arr[0] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatAppendStringFail() - { - $arr = new RepeatedField(GPBType::FLOAT); - $arr[] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatSetStringFail() - { - $arr = new RepeatedField(GPBType::FLOAT); - $arr[] = 0.0; - $arr[0] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatAppendMessageFail() - { - $arr = new RepeatedField(GPBType::FLOAT); - $arr[] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatSetMessageFail() - { - $arr = new RepeatedField(GPBType::FLOAT); - $arr[] = 0.0; - $arr[0] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleAppendStringFail() - { - $arr = new RepeatedField(GPBType::DOUBLE); - $arr[] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleSetStringFail() - { - $arr = new RepeatedField(GPBType::DOUBLE); - $arr[] = 0.0; - $arr[0] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleAppendMessageFail() - { - $arr = new RepeatedField(GPBType::DOUBLE); - $arr[] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleSetMessageFail() - { - $arr = new RepeatedField(GPBType::DOUBLE); - $arr[] = 0.0; - $arr[0] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testBoolAppendMessageFail() - { - $arr = new RepeatedField(GPBType::BOOL); - $arr[] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testBoolSetMessageFail() - { - $arr = new RepeatedField(GPBType::BOOL); - $arr[] = true; - $arr[0] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringAppendMessageFail() - { - $arr = new RepeatedField(GPBType::STRING); - $arr[] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringSetMessageFail() - { - $arr = new RepeatedField(GPBType::STRING); - $arr[] = 'abc'; - $arr[0] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringAppendInvalidUTF8Fail() - { - $arr = new RepeatedField(GPBType::STRING); - $hex = hex2bin("ff"); - $arr[] = $hex; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringSetInvalidUTF8Fail() - { - $arr = new RepeatedField(GPBType::STRING); - $arr[] = 'abc'; - $hex = hex2bin("ff"); - $arr[0] = $hex; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageAppendIntFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $arr[] = 1; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetIntFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $arr[] = new TestMessage_Sub; - $arr[0] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageAppendStringFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $arr[] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetStringFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $arr[] = new TestMessage_Sub; - $arr[0] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageAppendOtherMessageFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $arr[] = new TestMessage; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageAppendNullFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $null = null; - $arr[] = $null; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetNullFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $arr[] = new TestMessage_Sub(); - $null = null; - $arr[0] = $null; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testRemoveMiddleFail() - { - $arr = new RepeatedField(GPBType::INT32); - - $arr[] = 0; - $arr[] = 1; - $arr[] = 2; - $this->assertSame(3, count($arr)); - - unset($arr[1]); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testRemoveEmptyFail() - { - $arr = new RepeatedField(GPBType::INT32); - - unset($arr[0]); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageOffsetFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr[] = 0; - $arr[new TestMessage_Sub()] = 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringOffsetFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr[] = 0; - $arr['abc'] = 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testSetNonExistedOffsetFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr[0] = 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32FieldInvalidTypeFail() - { - $m = new TestMessage(); - $m->setOptionalInt32(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32FieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalInt32('abc'); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32FieldInvalidTypeFail() - { - $m = new TestMessage(); - $m->setOptionalUint32(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32FieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalUint32('abc'); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64FieldInvalidTypeFail() - { - $m = new TestMessage(); - $m->setOptionalInt64(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64FieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalInt64('abc'); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64FieldInvalidTypeFail() - { - $m = new TestMessage(); - $m->setOptionalUint64(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64FieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalUint64('abc'); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatFieldInvalidTypeFail() - { - $m = new TestMessage(); - $m->setOptionalFloat(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatFieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalFloat('abc'); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleFieldInvalidTypeFail() - { - $m = new TestMessage(); - $m->setOptionalDouble(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleFieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalDouble('abc'); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testBoolFieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalBool(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringFieldInvalidUTF8Fail() - { - $m = new TestMessage(); - $hex = hex2bin("ff"); - $m->setOptionalString($hex); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageFieldWrongTypeFail() - { - $m = new TestMessage(); - $a = 1; - $m->setOptionalMessage($a); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageFieldWrongClassFail() - { - $m = new TestMessage(); - $m->setOptionalMessage(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testRepeatedFieldWrongTypeFail() - { - $m = new TestMessage(); - $a = 1; - $m->setRepeatedInt32($a); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testRepeatedFieldWrongObjectFail() - { - $m = new TestMessage(); - $m->setRepeatedInt32($m); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testRepeatedFieldWrongRepeatedTypeFail() - { - $m = new TestMessage(); - - $repeated_int32 = new RepeatedField(GPBType::UINT32); - $m->setRepeatedInt32($repeated_int32); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testRepeatedFieldWrongRepeatedMessageClassFail() - { - $m = new TestMessage(); - - $repeated_message = new RepeatedField(GPBType::MESSAGE, - TestMessage::class); - $m->setRepeatedMessage($repeated_message); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMapFieldWrongTypeFail() - { - $m = new TestMessage(); - $a = 1; - $m->setMapInt32Int32($a); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMapFieldWrongObjectFail() - { - $m = new TestMessage(); - $m->setMapInt32Int32($m); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMapFieldWrongRepeatedTypeFail() - { - $m = new TestMessage(); - - $map_uint32_uint32 = new MapField(GPBType::UINT32, GPBType::UINT32); - $m->setMapInt32Int32($map_uint32_uint32); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMapFieldWrongRepeatedMessageClassFail() - { - $m = new TestMessage(); - - $map_int32_message = new MapField(GPBType::INT32, - GPBType::MESSAGE, - TestMessage::class); - $m->setMapInt32Message($map_int32_message); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageMergeFromInvalidTypeFail() - { - $m = new TestMessage(); - $n = new TestMessage_Sub(); - $m->mergeFrom($n); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32SetStringKeyFail() - { - $arr = new MapField(GPBType::INT32, GPBType::INT32); - $arr['abc'] = 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32SetStringValueFail() - { - $arr = new MapField(GPBType::INT32, GPBType::INT32); - $arr[0] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32SetMessageKeyFail() - { - $arr = new MapField(GPBType::INT32, GPBType::INT32); - $arr[new TestMessage_Sub()] = 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32SetMessageValueFail() - { - $arr = new MapField(GPBType::INT32, GPBType::INT32); - $arr[0] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32SetStringKeyFail() - { - $arr = new MapField(GPBType::UINT32, GPBType::UINT32); - $arr['abc'] = 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32SetStringValueFail() - { - $arr = new MapField(GPBType::UINT32, GPBType::UINT32); - $arr[0] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32SetMessageKeyFail() - { - $arr = new MapField(GPBType::UINT32, GPBType::UINT32); - $arr[new TestMessage_Sub()] = 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32SetMessageValueFail() - { - $arr = new MapField(GPBType::UINT32, GPBType::UINT32); - $arr[0] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64SetStringKeyFail() - { - $arr = new MapField(GPBType::INT64, GPBType::INT64); - $arr['abc'] = 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64SetStringValueFail() - { - $arr = new MapField(GPBType::INT64, GPBType::INT64); - $arr[0] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64SetMessageKeyFail() - { - $arr = new MapField(GPBType::INT64, GPBType::INT64); - $arr[new TestMessage_Sub()] = 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64SetMessageValueFail() - { - $arr = new MapField(GPBType::INT64, GPBType::INT64); - $arr[0] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64SetStringKeyFail() - { - $arr = new MapField(GPBType::UINT64, GPBType::UINT64); - $arr['abc'] = 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64SetStringValueFail() - { - $arr = new MapField(GPBType::UINT64, GPBType::UINT64); - $arr[0] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64SetMessageKeyFail() - { - $arr = new MapField(GPBType::UINT64, GPBType::UINT64); - $arr[new TestMessage_Sub()] = 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64SetMessageValueFail() - { - $arr = new MapField(GPBType::UINT64, GPBType::UINT64); - $arr[0] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleSetStringValueFail() - { - $arr = new MapField(GPBType::INT64, GPBType::DOUBLE); - $arr[0] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleSetMessageValueFail() - { - $arr = new MapField(GPBType::INT64, GPBType::DOUBLE); - $arr[0] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testBoolSetMessageKeyFail() - { - $arr = new MapField(GPBType::BOOL, GPBType::BOOL); - $arr[new TestMessage_Sub()] = true; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testBoolSetMessageValueFail() - { - $arr = new MapField(GPBType::BOOL, GPBType::BOOL); - $arr[true] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringSetInvalidUTF8KeyFail() - { - $arr = new MapField(GPBType::STRING, GPBType::STRING); - $arr[hex2bin("ff")] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringSetInvalidUTF8ValueFail() - { - $arr = new MapField(GPBType::STRING, GPBType::STRING); - $arr['abc'] = hex2bin("ff"); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringSetMessageKeyFail() - { - $arr = new MapField(GPBType::STRING, GPBType::STRING); - $arr[new TestMessage_Sub()] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringSetMessageValueFail() - { - $arr = new MapField(GPBType::STRING, GPBType::STRING); - $arr['abc'] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetIntValueFail() - { - $arr = - new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); - $arr[0] = 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetStringValueFail() - { - $arr = - new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); - $arr[0] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetOtherMessageValueFail() - { - $arr = - new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); - $arr[0] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetNullFail() - { - $arr = - new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); - $null = NULL; - $arr[0] = $null; - } - -} diff --git a/third_party/protobuf/3.4.0/php/tests/well_known_test.php b/third_party/protobuf/3.4.0/php/tests/well_known_test.php deleted file mode 100644 index 0c2aec13a9..0000000000 --- a/third_party/protobuf/3.4.0/php/tests/well_known_test.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -use Google\Protobuf\GPBEmpty; - -class WellKnownTest extends PHPUnit_Framework_TestCase { - - public function testNone() - { - $msg = new GPBEmpty(); - } - - public function testImportDescriptorProto() - { - $msg = new TestImportDescriptorProto(); - } - -} |