BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

testingview.class.php 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. class TestingView
  3. {
  4. /**
  5. * Render the linkbox
  6. */
  7. public static function render_linkbox($Page) { ?>
  8. <div class="linkbox">
  9. <?php if ($Page != "classes") { ?>
  10. <a href="testing.php" class="brackets">Classes</a>
  11. <?php }
  12. if ($Page != "comments") { ?>
  13. <a href="testing.php?action=comments" class="brackets">Comments</a>
  14. <?php } ?>
  15. </div>
  16. <?php }
  17. /**
  18. * Render a list of classes
  19. */
  20. public static function render_classes($Classes) { ?>
  21. <table>
  22. <tr class="colhead">
  23. <td>
  24. Class
  25. </td>
  26. <td>
  27. Testable functions
  28. </td>
  29. </tr>
  30. <?php foreach ($Classes as $Key => $Value) {
  31. $Doc = Testing::get_class_comment($Key);
  32. $Methods = count(Testing::get_testable_methods($Key)); ?>
  33. <tr>
  34. <td>
  35. <a href="testing.php?action=class&amp;name=<?=$Key?>"
  36. class="tooltip" title="<?=$Doc?>"><?=$Key?></a>
  37. </td>
  38. <td>
  39. <?=$Methods?>
  40. </td>
  41. </tr>
  42. <?php
  43. } ?>
  44. </table>
  45. <?php }
  46. /**
  47. * Render functions in a class
  48. */
  49. public static function render_functions($Methods)
  50. {
  51. foreach ($Methods as $Index => $Method) {
  52. $ClassName = $Method->getDeclaringClass()->getName();
  53. $MethodName = $Method->getName(); ?>
  54. <div class="box">
  55. <div class="head">
  56. <span><?=self::render_method_definition($Method)?></span>
  57. <span class="float_right">
  58. <a data-toggle-target="#method_params_<?=$Index?>"
  59. class="brackets">Params</a>
  60. <a href="#" class="brackets run" data-gazelle-id="<?=$Index?>"
  61. data-gazelle-class="<?=$ClassName?>"
  62. data-gazelle-method="<?=$MethodName?>">Run</a>
  63. </span>
  64. </div>
  65. <div class="pad hidden" id="method_params_<?=$Index?>">
  66. <?self::render_method_params($Method); ?>
  67. </div>
  68. <div class="pad hidden" id="method_results_<?=$Index?>">
  69. </div>
  70. </div>
  71. <?php
  72. }
  73. }
  74. /**
  75. * Render method parameters
  76. */
  77. private static function render_method_params($Method) { ?>
  78. <table>
  79. <?php foreach ($Method->getParameters() as $Parameter) {
  80. $DefaultValue = $Parameter->isDefaultValueAvailable() ? $Parameter->getDefaultValue() : ""; ?>
  81. <tr>
  82. <td class="label">
  83. <?=$Parameter->getName()?>
  84. </td>
  85. <td>
  86. <input type="text" name="<?=$Parameter->getName()?>"
  87. value="<?=$DefaultValue?>" />
  88. </td>
  89. </tr>
  90. <?php
  91. } ?>
  92. </table>
  93. <?php }
  94. /**
  95. * Render the method definition
  96. */
  97. private static function render_method_definition($Method)
  98. {
  99. $Title = "<span class='tooltip' title='" . Testing::get_method_comment($Method) . "'>" . $Method->getName() . "</span> (";
  100. foreach ($Method->getParameters() as $Parameter) {
  101. $Color = "red";
  102. if ($Parameter->isDefaultValueAvailable()) {
  103. $Color = "green";
  104. }
  105. $Title .= "<span style='color: $Color'>";
  106. $Title .= "$" . $Parameter->getName();
  107. if ($Parameter->isDefaultValueAvailable()) {
  108. $Title .= " = " . $Parameter->getDefaultValue();
  109. }
  110. $Title .= "</span>";
  111. $Title .= ", ";
  112. }
  113. $Title = rtrim($Title, ", ");
  114. $Title .= ")";
  115. return $Title;
  116. }
  117. /**
  118. * Renders class documentation stats
  119. */
  120. public static function render_missing_documentation($Classes) { ?>
  121. <table>
  122. <tr class="colhead">
  123. <td>
  124. Class
  125. </td>
  126. <td>
  127. Class documented
  128. </td>
  129. <td>
  130. Undocumented functions
  131. </td>
  132. <td>
  133. Documented functions
  134. </td>
  135. </tr>
  136. <?php foreach ($Classes as $Key => $Value) {
  137. $ClassComment = Testing::get_class_comment($Key); ?>
  138. <tr>
  139. <td>
  140. <?=$Key?>
  141. </td>
  142. <td>
  143. <?=!empty($ClassComment) ? "Yes" : "No"?>
  144. <td>
  145. <?=count(Testing::get_undocumented_methods($Key))?>
  146. </td>
  147. <td>
  148. <?=count(Testing::get_documented_methods($Key))?>
  149. </td>
  150. </tr>
  151. <?php
  152. } ?>
  153. </table>
  154. <?php }
  155. /**
  156. * Pretty print any data
  157. */
  158. public static function render_results($Data)
  159. {
  160. $Results = '<pre><ul style="list-style-type: none">';
  161. if (is_array($Data)) {
  162. foreach ($Data as $Key => $Value) {
  163. if (is_array($Value)) {
  164. $Results .= '<li>' . $Key . ' => ' . self::render_results($Value) . '</li>';
  165. } else {
  166. $Results .= '<li>' . $Key . ' => ' . $Value . '</li>';
  167. }
  168. }
  169. } else {
  170. $Results .= '<li>' . $Data . '</li>';
  171. }
  172. $Results .= '</ul></pre>';
  173. echo $Results;
  174. }
  175. }