PHP Unit Testing Framework 1
A Unit testing framework for PHP.

xhtml_test_runner.php

Go to the documentation of this file.
00001 <?php
00035 
00036 require_once 'xml_test_runner_with_style_sheet.php';
00037 
00045 class XHTMLTestRunner extends XMLTestRunnerWithStyleSheet
00046 {
00050   public function __construct()
00051   {
00052     parent::__construct();
00053     $this->styleSheet .= <<<END_OF_STYLE_SHEET
00054 <xsl:output method="xml" indent="yes"/>
00055 <xsl:template match="/testresults">
00056 <xsl:text disable-output-escaping="yes">
00057 &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot;
00058                   &quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&quot;&gt;
00059 </xsl:text>      
00060 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
00061   <head>
00062     <meta http-equiv="content-type" content="application/xhtml+xml; charset=US-ASCII" />
00063     <title>Test Case Report</title>
00064     <style type="text/css">
00065 /* http://meyerweb.com/eric/tools/css/reset/ */
00066 /* v1.0 | 20080212 */
00067 
00068 html, body, div, span, applet, object, iframe,
00069 h1, h2, h3, h4, h5, h6, p, blockquote, pre,
00070 a, abbr, acronym, address, big, cite, code,
00071 del, dfn, em, font, img, ins, kbd, q, s, samp,
00072 small, strike, strong, sub, sup, tt, var,
00073 b, u, i, center,
00074 dl, dt, dd, ol, ul, li,
00075 fieldset, form, label, legend,
00076 table, caption, tbody, tfoot, thead, tr, th, td {
00077   margin: 0;
00078   padding: 0;
00079   border: 0;
00080   outline: 0;
00081   font-size: 100%;
00082   vertical-align: baseline;
00083   background: transparent;
00084 }
00085 body {
00086   line-height: 1;
00087 }
00088 
00089 /* tables still need 'cellspacing="0"' in the markup */
00090 table {
00091   border-collapse: collapse;
00092   border-spacing: 0;
00093 }
00094 
00095 /* END OF THE RESET BIT */
00096 
00097 /* Stylesheet for the page */
00098 html
00099 {
00100   background-color: #ECFAFF;
00101 }
00102 
00103 body
00104 {
00105   margin: 10px auto 10px auto;
00106   width: 980px;
00107 }
00108 
00109 h1
00110 {
00111   margin-bottom: 5px;
00112   background-color: #BAEEA8;
00113   color: #BA21E0;
00114   font: bold 24px "Comic Sans MS", cursive;
00115   text-align: center;
00116 }
00117 
00118 h2
00119 {
00120   font: 18px Impact, Charcoal, sans-serif;
00121   color: Black;
00122   margin-bottom: 12px;
00123   margin-top: 12px;
00124 }
00125 
00126 h3
00127 {
00128   font: 14px "Arial Black", Gadget, sans-serif;
00129   color: #BA21E0;
00130   margin-top: 12px;
00131   margin-bottom: 12px;
00132   padding-top: 2px;
00133   padding-bottom: 2px;
00134 }
00135 
00136 a
00137 {
00138   text-decoration: none;
00139   color: inherit;
00140 }
00141 
00142 tr
00143 {
00144   color: Black;
00145   border: solid 1px black
00146 }
00147 
00148 td, th
00149 {
00150   border: solid 1px black;
00151   padding: 2px 2px 2px 2px;
00152   font: 12px Arial, Helvetica, sans-serif;
00153 }
00154 
00155 th
00156 {
00157   font-weight: bold;
00158   border-bottom-width: 2px;
00159   background-color: #A8E4FF;
00160   color: Black;
00161   border: solid 1px black
00162 }
00163 
00164 p
00165 {
00166   font: 12px Arial, Helvetica, sans-serif;
00167   margin-top: 10px;
00168   margin-bottom: 10px;
00169 }
00170 
00171 ul
00172 {
00173   margin-left: 15px;
00174   margin-top: 12px;
00175   font: 12px Arial, Helvetica, sans-serif;
00176   list-style: none;
00177 }
00178 
00179 strong
00180 {
00181   font-weight: bold;
00182 }
00183 
00184 .pass
00185 {
00186   background-color: #008000;
00187   color: White;
00188 }
00189 
00190 .passHeading
00191 {
00192   background-color: #008000;
00193   color: White;
00194   padding-left: 6px;
00195   padding-top: 2px;
00196   padding-bottom: 2px;
00197 }
00198 
00199 .fail
00200 {
00201   background-color: #900000;
00202   color: White;
00203 }
00204 
00205 .failHeading
00206 {
00207   background-color: #900000;
00208   color: White;
00209   padding-left: 6px;
00210   padding-top: 2px;
00211   padding-bottom: 2px;
00212 }
00213 
00214 .footnote
00215 {
00216   vertical-align: super;
00217   color: Black;
00218 }
00219 
00220 .centre
00221 {
00222   text-align: center;
00223 }
00224 
00225 .detailsTable
00226 {
00227   width: 980px;
00228 }
00229 
00230 .dateAndTimeColumn
00231 {
00232   width: 180px;
00233 }
00234 
00235 .eventColumn
00236 {
00237   width: 70px;
00238   text-align: center;
00239 }
00240 
00241 .reasonColumn
00242 {
00243   width: 170px;
00244 }
00245 
00246 .messageColumn
00247 {
00248   width: 170px;
00249 }
00250 
00251 .blankMessageColumn
00252 {
00253   width: 170px;
00254   text-align: center;
00255 }
00256 
00257 .detailsHeadingColumn
00258 {
00259   width: 105px;
00260   color: Yellow;
00261 }
00262 
00263 .testCaseIDColumn
00264 {
00265   width: 120px;
00266 }
00267 
00268 .nameColumn
00269 {
00270   width: 200px;
00271 }
00272 
00273 .descriptionColumn
00274 {
00275   width: 400px;
00276 }
00277 
00278 .hasPassedColumn
00279 {
00280   width: 60px;
00281 
00282 }
00283 .testCaseIDColumn
00284 {
00285   width: 120px;
00286 }
00287 
00288 .nameColumn
00289 {
00290   width: 200px;
00291 }
00292 
00293 .descriptionColumn
00294 {
00295   width: 400px;
00296 }
00297 
00298 .hasPassedColumn
00299 {
00300   width: 60px;
00301   text-align: center;
00302 }    </style>
00303   </head>
00304   <body>
00305     <h1>Test Case Report</h1>
00306     <h2>Summary</h2>
00307     <table cellspacing="0" title="Summary of tests" summary="A list of tests carried out and if they passed or failed">
00308       <thead>
00309         <tr>
00310           <th class="testCaseIDColumn">Test case ID</th>
00311           <th class="nameColumn">Name</th>
00312           <th class="descriptionColumn">Description</th>
00313           <th class="hasPassedColumn">Passed?</th>
00314         </tr>
00315       </thead>
00316       <tbody>
00317         <xsl:for-each select="testcase">
00318           <xsl:if test="passed = 'Yes'">
00319             <tr class="pass">
00320               <td class="testCaseIDColumn">
00321                 <a href="#{generate-id(id)}">
00322                   <xsl:value-of select="id"/>
00323                 </a>
00324               </td>
00325               <td class="nameColumn"><xsl:value-of select="name"/></td>
00326               <td class="descriptionColumn"><xsl:value-of select="description"/></td>
00327               <td class="hasPassedColumn"><xsl:value-of select="passed"/></td>
00328             </tr>
00329           </xsl:if>
00330           <xsl:if test="passed != 'Yes'">
00331             <tr class="fail">
00332               <td class="testCaseIDColumn">
00333                 <a href="#{generate-id(id)}">
00334                   <xsl:value-of select="id"/>
00335                 </a>
00336               </td>
00337               <td class="nameColumn"><xsl:value-of select="name"/></td>
00338               <td class="descriptionColumn"><xsl:value-of select="description"/></td>
00339               <td class="hasPassedColumn"><xsl:value-of select="passed"/></td>
00340             </tr>
00341           </xsl:if>
00342         </xsl:for-each>
00343       </tbody>
00344     </table>
00345     
00346     <h2>Details</h2>
00347     <xsl:for-each select="testcase">
00348       <xsl:if test="passed = 'Yes'">
00349         <h3 class="passHeading">
00350           <a id="{generate-id(id)}">
00351             <xsl:value-of select="id"/> - <xsl:value-of select="name"/>
00352           </a>
00353         </h3>
00354       </xsl:if>
00355       <xsl:if test="passed != 'Yes'">
00356         <h3 class="failHeading">
00357           <a id="{generate-id(id)}">
00358             <xsl:value-of select="id"/> - <xsl:value-of select="name"/>
00359           </a>
00360         </h3>
00361       </xsl:if>
00362  
00363       <p><xsl:value-of select="description"/></p>
00364       
00365       <table cellspacing="0" class="detailsTable" title="Test events" summary="A list of events that occurred during the test">
00366         <thead>
00367           <tr>
00368             <th class="dateAndTimeColumn">Date &amp; Time</th>
00369             <th class="eventColumn">Event<a href="#eventsKey" class="footnote">1</a></th>
00370             <th class="reasonColumn">Reason</th>
00371             <th class="messageColumn">Message</th>
00372             <th class="detailsColumn" colspan="2">Details</th>
00373           </tr>
00374         </thead>
00375         <tbody>
00376           <xsl:for-each select="listOfEvents/event">
00377             <xsl:choose>
00378               <xsl:when test="type = 'PASS'">
00379                 <tr class="pass">
00380                   <td rowspan="6" class="dateAndTimeColumn"><xsl:value-of select="time"/></td>
00381                   <td rowspan="6" class="eventColumn">PASS</td>
00382                   <td rowspan="6" class="reasonColumn"><xsl:value-of select="reason"/></td>
00383                   <td rowspan="6" class="messageColumn"><xsl:value-of select="message"/></td>
00384                   <td class="detailsHeadingColumn">File:</td>
00385                   <td><xsl:value-of select="file"/></td>
00386                 </tr>
00387                 <tr class="pass">
00388                   <td class="detailsHeadingColumn">Line:</td>
00389                   <td><xsl:value-of select="line"/></td>
00390                 </tr>
00391                 <tr class="pass">
00392                   <td class="detailsHeadingColumn">Actual Type:</td>
00393                   <td><pre><xsl:value-of select="actual/type"/></pre></td>
00394                 </tr>
00395                 <tr class="pass">
00396                   <td class="detailsHeadingColumn">Actual:</td>
00397                   <td><pre><xsl:value-of select="actual/value"/></pre></td>
00398                 </tr>
00399                 <tr class="pass">
00400                   <td class="detailsHeadingColumn">Comparison Type:</td>
00401                   <td><pre><xsl:value-of select="comparison/type"/></pre></td>
00402                 </tr>
00403                 <tr class="pass">
00404                   <td class="detailsHeadingColumn">Comparison:</td>
00405                   <td><pre><xsl:value-of select="comparison/value"/></pre></td>
00406                 </tr>
00407               </xsl:when>
00408               <xsl:when test="type = 'PASS_MSG'">
00409                 <tr class="pass">
00410                   <td rowspan="2" class="dateAndTimeColumn"><xsl:value-of select="time"/></td>
00411                   <td rowspan="2" class="eventColumn">PASS_MSG</td>
00412                   <td rowspan="2" class="reasonColumn">Users pass message</td>
00413                   <td rowspan="2" class="messageColumn"><xsl:value-of select="message"/></td>
00414                   <td class="detailsHeadingColumn">File:</td>
00415                   <td><xsl:value-of select="file"/></td>
00416                 </tr>
00417                 <tr class="pass">
00418                   <td class="detailsHeadingColumn">Line:</td>
00419                   <td><xsl:value-of select="line"/></td>
00420                 </tr>
00421               </xsl:when>
00422               <xsl:when test="type = 'FAIL'">
00423                 <tr class="fail">
00424                   <td rowspan="6" class="dateAndTimeColumn"><xsl:value-of select="time"/></td>
00425                   <td rowspan="6" class="eventColumn">FAIL</td>
00426                   <td rowspan="6" class="reasonColumn"><xsl:value-of select="reason"/></td>
00427                   <td rowspan="6" class="messageColumn"><xsl:value-of select="message"/></td>
00428                   <td class="detailsHeadingColumn">File:</td>
00429                   <td><xsl:value-of select="file"/></td>
00430                 </tr>
00431                 <tr class="fail">
00432                   <td class="detailsHeadingColumn">Line:</td>
00433                   <td><xsl:value-of select="line"/></td>
00434                 </tr>
00435                 <tr class="fail">
00436                   <td class="detailsHeadingColumn">Actual Type:</td>
00437                   <td><pre><xsl:value-of select="actual/type"/></pre></td>
00438                 </tr>
00439                 <tr class="fail">
00440                   <td class="detailsHeadingColumn">Actual:</td>
00441                   <td><pre><xsl:value-of select="actual/value"/></pre></td>
00442                 </tr>
00443                 <tr class="fail">
00444                   <td class="detailsHeadingColumn">Comparison Type:</td>
00445                   <td><pre><xsl:value-of select="comparison/type"/></pre></td>
00446                 </tr>
00447                 <tr class="fail">
00448                   <td class="detailsHeadingColumn">Comparison:</td>
00449                   <td><pre><xsl:value-of select="comparison/value"/></pre></td>
00450                 </tr>
00451               </xsl:when>
00452               <xsl:when test="type = 'FAIL_MSG'">
00453                 <tr class="fail">
00454                   <td rowspan="2" class="dateAndTimeColumn"><xsl:value-of select="time"/></td>
00455                   <td rowspan="2" class="eventColumn">FAIL_MSG</td>
00456                   <td rowspan="2" class="reasonColumn">Users fail message</td>
00457                   <td rowspan="2" class="messageColumn"><xsl:value-of select="message"/></td>
00458                   <td class="detailsHeadingColumn">File:</td>
00459                   <td><xsl:value-of select="file"/></td>
00460                 </tr>
00461                 <tr class="fail">
00462                   <td class="detailsHeadingColumn">Line:</td>
00463                   <td><xsl:value-of select="line"/></td>
00464                 </tr>
00465               </xsl:when>
00466               <xsl:when test="type = 'ERROR'">
00467                 <tr class="fail">
00468                   <td rowspan="6" class="dateAndTimeColumn"><xsl:value-of select="time"/></td>
00469                   <td rowspan="6" class="eventColumn">ERROR</td>
00470                   <td rowspan="6" class="reasonColumn"><xsl:value-of select="reason"/></td>
00471                   <td rowspan="6" class="messageColumn"><xsl:value-of select="message"/></td>
00472                   <td class="detailsHeadingColumn">File:</td>
00473                   <td><xsl:value-of select="file"/></td>
00474                 </tr>
00475                 <tr class="fail">
00476                   <td class="detailsHeadingColumn">Line:</td>
00477                   <td><xsl:value-of select="line"/></td>
00478                 </tr>
00479                 <tr class="fail">
00480                   <td class="detailsHeadingColumn">Actual Type:</td>
00481                   <td><pre><xsl:value-of select="actual/type"/></pre></td>
00482                 </tr>
00483                 <tr class="fail">
00484                   <td class="detailsHeadingColumn">Actual:</td>
00485                   <td><pre><xsl:value-of select="actual/value"/></pre></td>
00486                 </tr>
00487                 <tr class="fail">
00488                   <td class="detailsHeadingColumn">Comparison Type:</td>
00489                   <td><pre><xsl:value-of select="comparison/type"/></pre></td>
00490                 </tr>
00491                 <tr class="fail">
00492                   <td class="detailsHeadingColumn">Comparison:</td>
00493                   <td><pre><xsl:value-of select="comparison/value"/></pre></td>
00494                 </tr>
00495               </xsl:when>
00496               <xsl:when test="type = 'USER_MSG'">
00497                 <tr>
00498                   <td class="dateAndTimeColumn"><xsl:value-of select="time"/></td>
00499                   <td class="eventColumn">USER MSG</td>
00500                   <td class="reasonColumn">User message</td>
00501                   <td class="messageColumn"><xsl:value-of select="message"/></td>
00502                   <td colspan="2" class="centre">-</td>
00503                 </tr>
00504               </xsl:when>
00505               <xsl:when test="type = 'SYS_MSG'">
00506                 <tr>
00507                   <td class="dateAndTimeColumn"><xsl:value-of select="time"/></td>
00508                   <td class="eventColumn">SYS MSG</td>
00509                   <td class="reasonColumn"><xsl:value-of select="reason"/></td>
00510                   <td class="blankMessageColumn">-</td>
00511                   <td colspan="2" class="centre">-</td>
00512                 </tr>
00513               </xsl:when>
00514               <xsl:when test="type = 'EXCEPTION_THROWN'">
00515                 <tr class="fail">
00516                   <td rowspan="2" class="dateAndTimeColumn"><xsl:value-of select="time"/></td>
00517                   <td rowspan="2" class="eventColumn">EXCEPTION</td>
00518                   <td rowspan="2" class="reasonColumn"><xsl:value-of select="reason"/></td>
00519                   <td rowspan="2" class="messageColumn"><xsl:value-of select="message"/></td>
00520                   <td class="detailsHeadingColumn">File:</td>
00521                   <td><xsl:value-of select="file"/></td>
00522                 </tr>
00523                 <tr class="fail">
00524                   <td class="detailsHeadingColumn">Line:</td>
00525                   <td><xsl:value-of select="line"/></td>
00526                 </tr>
00527               </xsl:when>
00528               <xsl:when test="type = 'START_SETUP'">
00529                 <tr>
00530                   <td class="dateAndTimeColumn"><xsl:value-of select="time"/></td>
00531                   <td class="eventColumn">TS</td>
00532                   <td class="reasonColumn">'SetUp' started</td>
00533                   <td class="blankMessageColumn">-</td>
00534                   <td colspan="2" class="centre">-</td>
00535                 </tr>
00536               </xsl:when>
00537               <xsl:when test="type = 'END_SETUP'">
00538                 <tr>
00539                   <td class="dateAndTimeColumn"><xsl:value-of select="time"/></td>
00540                   <td class="eventColumn">TS</td>
00541                   <td class="reasonColumn">'SetUp' finished</td>
00542                   <td class="blankMessageColumn">-</td>
00543                   <td colspan="2" class="centre">-</td>
00544                 </tr>
00545               </xsl:when>
00546               <xsl:when test="type = 'START_RUN'">
00547                 <tr>
00548                   <td class="dateAndTimeColumn"><xsl:value-of select="time"/></td>
00549                   <td class="eventColumn">TS</td>
00550                   <td class="reasonColumn">'Run' started</td>
00551                   <td class="blankMessageColumn">-</td>
00552                   <td colspan="2" class="centre">-</td>
00553                 </tr>
00554               </xsl:when>
00555               <xsl:when test="type = 'END_RUN'">
00556                 <tr>
00557                   <td class="dateAndTimeColumn"><xsl:value-of select="time"/></td>
00558                   <td class="eventColumn">TS</td>
00559                   <td class="reasonColumn">'Run' finished</td>
00560                   <td class="blankMessageColumn">-</td>
00561                   <td colspan="2" class="centre">-</td>
00562                 </tr>
00563               </xsl:when>
00564               <xsl:when test="type = 'START_TEAR_DOWN'">
00565                 <tr>
00566                   <td class="dateAndTimeColumn"><xsl:value-of select="time"/></td>
00567                   <td class="eventColumn">TS</td>
00568                   <td class="reasonColumn">'TearDown' started</td>
00569                   <td class="blankMessageColumn">-</td>
00570                   <td colspan="2" class="centre">-</td>
00571                 </tr>
00572               </xsl:when>
00573               <xsl:when test="type = 'END_TEAR_DOWN'">
00574                 <tr>
00575                   <td class="dateAndTimeColumn"><xsl:value-of select="time"/></td>
00576                   <td class="eventColumn">TS</td>
00577                   <td class="reasonColumn">'TearDown' finished</td>
00578                   <td class="blankMessageColumn">-</td>
00579                   <td colspan="2" class="centre">-</td>
00580                 </tr>
00581               </xsl:when>
00582             </xsl:choose>
00583           </xsl:for-each>
00584         </tbody>
00585       </table>
00586     </xsl:for-each>
00587     
00588     <h2><a id="eventsKey">Events key</a></h2>
00589     <p>A list of events that can occur in a test along with their meaning:</p>
00590     <ul>
00591       <li><strong>PASS</strong> - An assertion has passed successfully</li>
00592       <li><strong>PASS_MSG</strong> - A users pass message</li>
00593       <li><strong>FAIL</strong> - An assertion has failed</li>
00594       <li><strong>FAIL_MSG</strong> - A users fail message</li>
00595       <li><strong>ERROR</strong> - An assertion could not be carried out - need to fix the code!</li>
00596       <li><strong>USER MSG</strong> - A user message, for comentary</li>
00597       <li><strong>SYS MSG</strong> - A test system message</li>
00598       <li><strong>EXCEPTION</strong> - An exception has thrown and uncaught - need to fix the code!</li>
00599       <li><strong>TS</strong> - A time stamp marker</li>
00600     </ul>
00601   </body>
00602 </html>
00603   </xsl:template>
00604 </xsl:stylesheet>  
00605 END_OF_STYLE_SHEET;
00606   }
00607   
00624   public function Run(TestSuite &$suite,
00625                       $filename = null,
00626                       $extension = 'html')
00627   {
00628     return parent::Run($suite, $filename, $extension);
00629   }
00630 }
00631 ?>
 All Data Structures Files Functions Variables

© 2011, Ed Heal