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.6KB

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