From ae55fd2cc52849004de21a7e26aed7bfe393eaed Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Fri, 22 Sep 2017 14:08:01 -0700 Subject: Enforce all error report for php tests. (#3670) * Enforce all error report for php tests. * Import vendor/autoload.php in tests/bootstrap_phpunit.php --- Makefile.am | 1 + php/phpunit.xml | 2 +- php/src/Google/Protobuf/Internal/DescriptorPool.php | 20 ++++++++++++++++---- php/tests/autoload.php | 2 ++ php/tests/bootstrap_phpunit.php | 5 +++++ 5 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 php/tests/bootstrap_phpunit.php diff --git a/Makefile.am b/Makefile.am index 0c93debe..e41bdff9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -674,6 +674,7 @@ php_EXTRA_DIST= \ php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php \ php/tests/array_test.php \ php/tests/autoload.php \ + php/tests/bootstrap_phpunit.php \ php/tests/compatibility_test.sh \ php/tests/descriptors_test.php \ php/tests/encode_decode_test.php \ diff --git a/php/phpunit.xml b/php/phpunit.xml index d7077038..87440bbd 100644 --- a/php/phpunit.xml +++ b/php/phpunit.xml @@ -1,5 +1,5 @@ - diff --git a/php/src/Google/Protobuf/Internal/DescriptorPool.php b/php/src/Google/Protobuf/Internal/DescriptorPool.php index 65d1a884..304c1615 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorPool.php +++ b/php/src/Google/Protobuf/Internal/DescriptorPool.php @@ -109,18 +109,30 @@ class DescriptorPool public function getDescriptorByClassName($klass) { - return $this->class_to_desc[$klass]; + if (isset($this->class_to_desc[$klass])) { + return $this->class_to_desc[$klass]; + } else { + return null; + } } public function getEnumDescriptorByClassName($klass) { - return $this->class_to_enum_desc[$klass]; + if (isset($this->class_to_enum_desc[$klass])) { + return $this->class_to_enum_desc[$klass]; + } else { + return null; + } } public function getDescriptorByProtoName($proto) { - $klass = $this->proto_to_class[$proto]; - return $this->class_to_desc[$klass]; + if (isset($this->proto_to_class[$proto])) { + $klass = $this->proto_to_class[$proto]; + return $this->class_to_desc[$klass]; + } else { + return null; + } } public function getEnumDescriptorByProtoName($proto) diff --git a/php/tests/autoload.php b/php/tests/autoload.php index 0a917fc5..b98b13ab 100755 --- a/php/tests/autoload.php +++ b/php/tests/autoload.php @@ -1,5 +1,7 @@