Cradle  0.3.3
Simple library for creating Web-based applications
PutResults Class Reference

PhpUnit Tests Results visualisation. More...

Public Member Functions

 __construct ($targetPath="")
 
 setTargetPath ($targetPath="")
 
 getTargetPath ($targetPath=NULL)
 
 findAll ($targetPath=NULL)
 
 toHtml ()
 
 getJsContent ()
 

Data Fields

 $cssContainerDivClass = "testcases"
 
 $cssStatusOk = "status-ok"
 
 $cssStatusFail = "status-fail"
 
 $cssStatusError = "status-error"
 
 $cssTestSuite = "testsuite"
 
 $cssTestName = "testname"
 
 $cssDescription = "description"
 

Detailed Description

PhpUnit Tests Results visualisation.

Finds all xml-files with PHPUnit tests results, parse and represents it in HTML format.

Version
2.0
Author
Digger mrdig.nosp@m.ger@.nosp@m.sad-s.nosp@m.yste.nosp@m.ms.ru

Example of usage:

require_once 'autoload.php';
$results = new PutResults("/path/to/phpunit-test-results");
echo $results->toHtml(); //<-- out HTML code
echo $results->getJsContent(); //<-- out some Javascript code (require JQuery)
Note
This class requires Javascript libs:
  • JQuery

To colorize HTML output use css-file with next styles:

//--- statuses:
.testcases [data-testcase-ok] { color: #00aa00; }
.testcases [data-testcase-ok] > span:first-child { text-decoration: line-through; }
.testcases [data-testcase-fail] { color: #aa0000; }
.testcases [data-testcase-error] { color: #eb8f00; }
//--- main items
.testcases > ul > li { cursor: pointer; }
//--- comments
.testcases > ul > li > span {
color: #888888;
font-size: 0.9em;
font-style: italic;
}
//--- fail description:
.testcases > ul > li div {
color: #555555;
font-size: 0.9em;
padding: 2px 10px 10px 10px;
border-left: 1px solid #000000;
}

css class ".testcases" can be changed by $cssContainerDivClass property.

Constructor & Destructor Documentation

__construct (   $targetPath = "")

Constructor It is a main method

Parameters
string$targetPathPath to PHPUnit results xml-files.

Member Function Documentation

findAll (   $targetPath = NULL)

To find all existing PHPUnit results xml-files.

Parameters
string$targetPath(Option) new path to PHPUnit results xml-files.
Returns
array Array of testSuites structure:
Array (
[someFile.xml] => Array
(
[@attributes] => Array
(
[name] => someTest
[file] => someFile.xml
[tests] =>
[assertions] =>
[failures] => 1
[errors] =>
[time] =>
[base] => basePath
)
[testcase] => Array
(
[0] => Array
(
[@attributes] => Array
(
[name] =>
[class] =>
[file] =>
[line] =>
[assertions] =>
[time] =>
)
[failure] => some failure
)
)
[someFile2.xml] => Array( ... )
...
getJsContent ( )

Get Javascript content additions (Option)

Returns
string Javascript code.
getTargetPath (   $targetPath = NULL)

Get path to PHPUnit results xml-files. (Or set new target path)

Parameters
string$targetPath(Option) new path to PHPUnit results xml-files to set instead.
Returns
string Real target path.
setTargetPath (   $targetPath = "")

Set real path to PHPUnit results xml-files.

Parameters
string$targetPathPath to PHPUnit results xml-files.
Returns
string Real target path.
toHtml ( )

Represents testSuites structure in HTML format.

Returns
string HTML code:
<div class='$cssContainerDivClass'>
...
<ul>
<li class='$testsuite'><span>TestClassName1</span> <em>--> FileName1</em> </span>
<ul>
<li><div class='$testname'> test_methodName1 </div> </li>
<li><div class='$testname'> test_methodName2 </div> <div class='$description'> ... fail description ... </div></li>
...
</ul>
</li>
...
</ul>
</div>

Field Documentation

$cssContainerDivClass = "testcases"

string CSS class name for main container (div)

$cssStatusError = "status-error"

string Name of attribute of HTML li tag if test have error

$cssStatusFail = "status-fail"

string Name of attribute of HTML li tag if test is failed

$cssStatusOk = "status-ok"

string Name of attribute of HTML li tag if test is ok


The documentation for this class was generated from the following file: