浏览代码

Enforce all error report for php tests. (#3670)

* Enforce all error report for php tests.

* Import vendor/autoload.php in tests/bootstrap_phpunit.php
Paul Yang 8 年之前
父节点
当前提交
ae55fd2cc5
共有 5 个文件被更改,包括 25 次插入5 次删除
  1. 1 0
      Makefile.am
  2. 1 1
      php/phpunit.xml
  3. 16 4
      php/src/Google/Protobuf/Internal/DescriptorPool.php
  4. 2 0
      php/tests/autoload.php
  5. 5 0
      php/tests/bootstrap_phpunit.php

+ 1 - 0
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                                    \

+ 1 - 1
php/phpunit.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<phpunit bootstrap="./vendor/autoload.php"
+<phpunit bootstrap="./tests/bootstrap_phpunit.php"
          colors="true">
   <testsuites>
     <testsuite name="protobuf-tests">

+ 16 - 4
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)

+ 2 - 0
php/tests/autoload.php

@@ -1,5 +1,7 @@
 <?php
 
+error_reporting(E_ALL);
+
 function getGeneratedFiles($dir, &$results = array())
 {
     $files = scandir($dir);

+ 5 - 0
php/tests/bootstrap_phpunit.php

@@ -0,0 +1,5 @@
+<?php
+
+require_once("vendor/autoload.php");
+
+error_reporting(E_ALL);