Merge pull request #1 from civicrm/master
[civicrm-core.git] / Civi / CiUtil / PHPUnitScanner.php
index 132f654ff4e5e4288fcfd5016d165e4b8dc45eb9..a1028f52f5c8986f3f5088284e1d8cb9ba3f54f4 100644 (file)
@@ -1,20 +1,22 @@
 <?php
 namespace Civi\CiUtil;
+
 use Symfony\Component\Finder\Finder;
 
 /**
  * Search for PHPUnit test cases
  */
 class PHPUnitScanner {
+
   /**
-   * @return array<string> class names
+   * @param $path
+   * @return array <string> class names
    */
-  static function _findTestClasses($path) {
-//    print_r(array(
-//      'loading' => $path,
-//      get_included_files()
-//    ));
-
+  public static function _findTestClasses($path) {
+    //    print_r(array(
+    //      'loading' => $path,
+    //      get_included_files()
+    //    ));
     $origClasses = get_declared_classes();
     require_once $path;
     $newClasses = get_declared_classes();
@@ -26,10 +28,12 @@ class PHPUnitScanner {
   }
 
   /**
+   * @param $paths
    * @return array (string $file => string $class)
+   * @throws \Exception
    */
-  static function findTestClasses($paths) {
-    $testClasses = array();
+  public static function findTestClasses($paths) {
+    $testClasses = [];
     $finder = new Finder();
 
     foreach ($paths as $path) {
@@ -65,27 +69,30 @@ class PHPUnitScanner {
   }
 
   /**
-   * @param array $testClasses
-   * @return array each element is an array with keys:
+   * @param array $paths
+   *
+   * @return array
+   *   each element is an array with keys:
    *   - file: string
    *   - class: string
    *   - method: string
    */
-  static function findTestsByPath($paths) {
-    $r = array();
+  public static function findTestsByPath($paths) {
+    $r = [];
     $testClasses = self::findTestClasses($paths);
     foreach ($testClasses as $testFile => $testClass) {
       $clazz = new \ReflectionClass($testClass);
       foreach ($clazz->getMethods() as $method) {
         if (preg_match('/^test/', $method->name)) {
-          $r[] = array(
+          $r[] = [
             'file' => $testFile,
             'class' => $testClass,
-            'method' => $method->name
-          );
+            'method' => $method->name,
+          ];
         }
       }
     }
     return $r;
   }
+
 }