Oppaitime'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 5.1KB

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