<?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
*/
public static function _findTestClasses($path) {
-// print_r(array(
-// 'loading' => $path,
-// get_included_files()
-// ));
-
+ // print_r(array(
+ // 'loading' => $path,
+ // get_included_files()
+ // ));
$origClasses = get_declared_classes();
require_once $path;
$newClasses = get_declared_classes();
}
/**
+ * @param $paths
* @return array (string $file => string $class)
+ * @throws \Exception
*/
public static function findTestClasses($paths) {
- $testClasses = array();
+ $testClasses = [];
$finder = new Finder();
foreach ($paths as $path) {
}
/**
- * @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
*/
public static function findTestsByPath($paths) {
- $r = array();
+ $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;
}
+
}