Unverified Commit 4a0ad7b0 authored by Feng Xiao's avatar Feng Xiao Committed by GitHub

Merge pull request #4908 from TeBoring/php-bug

Fix php tests
parents 1ccb8d4b d7793016
...@@ -283,6 +283,7 @@ void build_class_from_descriptor( ...@@ -283,6 +283,7 @@ void build_class_from_descriptor(
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void Message_construct(zval* msg, zval* array_wrapper) { void Message_construct(zval* msg, zval* array_wrapper) {
TSRMLS_FETCH();
zend_class_entry* ce = Z_OBJCE_P(msg); zend_class_entry* ce = Z_OBJCE_P(msg);
MessageHeader* intern = NULL; MessageHeader* intern = NULL;
if (EXPECTED(class_added(ce))) { if (EXPECTED(class_added(ce))) {
......
...@@ -305,11 +305,8 @@ class GPBUtil ...@@ -305,11 +305,8 @@ class GPBUtil
$name, $name,
$file_proto) $file_proto)
{ {
$parts = explode('.', $name); $classname = implode('_', explode('.', $name));
foreach ($parts as $i => $part) { return static::getClassNamePrefix($classname, $file_proto) . $classname;
$parts[$i] = static::getClassNamePrefix($parts[$i], $file_proto) . $parts[$i];
}
return implode('\\', $parts);
} }
public static function getClassNameWithoutPackage( public static function getClassNameWithoutPackage(
......
...@@ -156,15 +156,22 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable ...@@ -156,15 +156,22 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
$this->checkKey($this->key_type, $key); $this->checkKey($this->key_type, $key);
switch ($this->value_type) { switch ($this->value_type) {
case GPBType::SFIXED32:
case GPBType::SINT32:
case GPBType::INT32: case GPBType::INT32:
case GPBType::ENUM:
GPBUtil::checkInt32($value); GPBUtil::checkInt32($value);
break; break;
case GPBType::FIXED32:
case GPBType::UINT32: case GPBType::UINT32:
GPBUtil::checkUint32($value); GPBUtil::checkUint32($value);
break; break;
case GPBType::SFIXED64:
case GPBType::SINT64:
case GPBType::INT64: case GPBType::INT64:
GPBUtil::checkInt64($value); GPBUtil::checkInt64($value);
break; break;
case GPBType::FIXED64:
case GPBType::UINT64: case GPBType::UINT64:
GPBUtil::checkUint64($value); GPBUtil::checkUint64($value);
break; break;
...@@ -249,36 +256,24 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable ...@@ -249,36 +256,24 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
private function checkKey($key_type, &$key) private function checkKey($key_type, &$key)
{ {
switch ($key_type) { switch ($key_type) {
case GPBType::SFIXED32:
case GPBType::SINT32:
case GPBType::INT32: case GPBType::INT32:
GPBUtil::checkInt32($key); GPBUtil::checkInt32($key);
break; break;
case GPBType::FIXED32:
case GPBType::UINT32: case GPBType::UINT32:
GPBUtil::checkUint32($key); GPBUtil::checkUint32($key);
break; break;
case GPBType::SFIXED64:
case GPBType::SINT64:
case GPBType::INT64: case GPBType::INT64:
GPBUtil::checkInt64($key); GPBUtil::checkInt64($key);
break; break;
case GPBType::UINT64:
GPBUtil::checkUint64($key);
break;
case GPBType::FIXED64: case GPBType::FIXED64:
case GPBType::UINT64:
GPBUtil::checkUint64($key); GPBUtil::checkUint64($key);
break; break;
case GPBType::FIXED32:
GPBUtil::checkUint32($key);
break;
case GPBType::SFIXED64:
GPBUtil::checkInt64($key);
break;
case GPBType::SFIXED32:
GPBUtil::checkInt32($key);
break;
case GPBType::SINT64:
GPBUtil::checkInt64($key);
break;
case GPBType::SINT32:
GPBUtil::checkInt32($key);
break;
case GPBType::BOOL: case GPBType::BOOL:
GPBUtil::checkBool($key); GPBUtil::checkBool($key);
break; break;
......
...@@ -141,15 +141,22 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable ...@@ -141,15 +141,22 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
public function offsetSet($offset, $value) public function offsetSet($offset, $value)
{ {
switch ($this->type) { switch ($this->type) {
case GPBType::SFIXED32:
case GPBType::SINT32:
case GPBType::INT32: case GPBType::INT32:
case GPBType::ENUM:
GPBUtil::checkInt32($value); GPBUtil::checkInt32($value);
break; break;
case GPBType::FIXED32:
case GPBType::UINT32: case GPBType::UINT32:
GPBUtil::checkUint32($value); GPBUtil::checkUint32($value);
break; break;
case GPBType::SFIXED64:
case GPBType::SINT64:
case GPBType::INT64: case GPBType::INT64:
GPBUtil::checkInt64($value); GPBUtil::checkInt64($value);
break; break;
case GPBType::FIXED64:
case GPBType::UINT64: case GPBType::UINT64:
GPBUtil::checkUint64($value); GPBUtil::checkUint64($value);
break; break;
...@@ -162,6 +169,9 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable ...@@ -162,6 +169,9 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
case GPBType::BOOL: case GPBType::BOOL:
GPBUtil::checkBool($value); GPBUtil::checkBool($value);
break; break;
case GPBType::BYTES:
GPBUtil::checkString($value, false);
break;
case GPBType::STRING: case GPBType::STRING:
GPBUtil::checkString($value, true); GPBUtil::checkString($value, true);
break; break;
......
...@@ -122,6 +122,8 @@ composer install ...@@ -122,6 +122,8 @@ composer install
tests=( array_test.php encode_decode_test.php generated_class_test.php map_field_test.php well_known_test.php ) 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 sed -i.bak '/php_implementation_test.php/d' phpunit.xml
sed -i.bak '/generated_phpdoc_test.php/d' phpunit.xml sed -i.bak '/generated_phpdoc_test.php/d' phpunit.xml
sed -i.bak 's/generated_phpdoc_test.php//g' tests/test.sh
sed -i.bak '/memory_leak_test.php/d' tests/test.sh
for t in "${tests[@]}" for t in "${tests[@]}"
do do
remove_error_test tests/$t remove_error_test tests/$t
......
...@@ -14,7 +14,7 @@ set -e ...@@ -14,7 +14,7 @@ set -e
phpize && ./configure CFLAGS='-g -O0' && make phpize && ./configure CFLAGS='-g -O0' && make
popd 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 ) tests=( array_test.php encode_decode_test.php generated_class_test.php map_field_test.php well_known_test.php descriptors_test.php )
for t in "${tests[@]}" for t in "${tests[@]}"
do do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment