diff --git a/classes/testing.class.php b/classes/testing.class.php new file mode 100644 index 00000000..89beda3c --- /dev/null +++ b/classes/testing.class.php @@ -0,0 +1,150 @@ +getName() === $Method) { + return true; + } + } + return false; + } + + /** + * Get testable methods in a class, a testable method has a @Test + */ + public static function get_testable_methods($Class) { + if (is_string($Class)) { + $ReflectionClass = self::$Classes[$Class]; + } else { + $ReflectionClass = $Class; + } + $ReflectionMethods = $ReflectionClass->getMethods(); + $TestableMethods = array(); + foreach($ReflectionMethods as $Method) { + if ($Method->isPublic() && $Method->isStatic() && strpos($Method->getDocComment(), "@Test")) { + $TestableMethods[] = $Method; + } + } + return $TestableMethods; + } + + + /** + * Get the class comment + */ + public static function get_class_comment($Class) { + $ReflectionClass = self::$Classes[$Class]; + return trim(str_replace(array("@TestClass", "*", "/"), "", $ReflectionClass->getDocComment())); + } + + /** + * Get the undocumented methods in a class + */ + public static function get_undocumented_methods($Class) { + $ReflectionClass = self::$Classes[$Class]; + $Methods = array(); + foreach($ReflectionClass->getMethods() as $Method) { + if (!$Method->getDocComment()) { + $Methods[] = $Method; + } + } + return $Methods; + } + + /** + * Get the documented methods + */ + public static function get_documented_methods($Class) { + $ReflectionClass = self::$Classes[$Class]; + $Methods = array(); + foreach($ReflectionClass->getMethods() as $Method) { + if ($Method->getDocComment()) { + $Methods[] = $Method; + } + } + return $Methods; + } + + /** + * Get all methods in a class + */ + public static function get_methods($Class) { + return self::$Classes[$Class]->getMethods(); + } + + /** + * Get a method comment + */ + public static function get_method_comment($Method) { + return trim(str_replace(array("*", "/"), "", $Method->getDocComment())); + } + +} \ No newline at end of file diff --git a/classes/testingview.class.php b/classes/testingview.class.php new file mode 100644 index 00000000..f5892dcb --- /dev/null +++ b/classes/testingview.class.php @@ -0,0 +1,175 @@ + + + + + + + + + $Value) { + $Doc = Testing::get_class_comment($Key); + $Methods = count(Testing::get_testable_methods($Key)); +?> + + + + + +
+ Class + + Testable functions +
+ + + +
+ $Method) { + $ClassName = $Method->getDeclaringClass()->getName(); + $MethodName = $Method->getName(); +?> +
+
+ + + Params + Run + +
+ + +
+ + +getParameters() as $Parameter) { + $DefaultValue = $Parameter->isDefaultValueAvailable() ? $Parameter->getDefaultValue() : ""; +?> + + + + + +
+ getName()?> + + +
+" . $Method->getName() . " ("; + foreach($Method->getParameters() as $Parameter) { + $Color = "red"; + if ($Parameter->isDefaultValueAvailable()) { + $Color = "green"; + } + $Title .= ""; + $Title .= "$" . $Parameter->getName(); + if ($Parameter->isDefaultValueAvailable()) { + $Title .= " = " . $Parameter->getDefaultValue(); + } + $Title .= ""; + $Title .= ", "; + + } + $Title = rtrim($Title, ", "); + $Title .= ")"; + return $Title; + } + + /** + * Renders class documentation stats + */ + public static function render_missing_documentation($Classes) { ?> + + + + + + + + $Value) { + $ClassComment = Testing::get_class_comment($Key); +?> + + + + + + +
+ Class + + Class documented + + Undocumented functions + + Documented functions +
+ + + + + + + +
+'; + echo $Results; + } + +} \ No newline at end of file diff --git a/classes/top10view.class.php b/classes/top10view.class.php index b732f237..c05f36b0 100644 --- a/classes/top10view.class.php +++ b/classes/top10view.class.php @@ -6,7 +6,7 @@ public static function render_linkbox($Selected) { ?>