Skip to content

Commit

Permalink
- Code browser task added and integrated into into example and projec…
Browse files Browse the repository at this point in the history
…t command

git-svn-id: svn://phpunit.de/phpunit/phpUnderControl/trunk@5377 c4a080f7-5c17-0410-a942-8af0f0140c7b
  • Loading branch information
manuelpichler committed Nov 19, 2009
1 parent 37a7573 commit 95ebad4
Show file tree
Hide file tree
Showing 8 changed files with 308 additions and 171 deletions.
2 changes: 1 addition & 1 deletion data/webapps/cruisecontrol/header.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<%@page import="java.io.File, java.util.Arrays"%>
<%@ taglib uri="/WEB-INF/cruisecontrol-jsp11.tld" prefix="cruisecontrol"%>

<h1>
<h1 id="phpUnderControlHeader">
<a href="<%=request.getContextPath() %>/index">
phpUnderControl
</a>
Expand Down
2 changes: 1 addition & 1 deletion data/webapps/cruisecontrol/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<link type="text/css" rel="stylesheet" href="<%=request.getContextPath() %>/css/php-under-control.css?v=3" />
<link rel="icon" href="<%=request.getContextPath() %>/favicon.ico" type="image/x-icon" />
</head>
<body onload="checkIframe('<%=request.getContextPath() %>/css/php-under-control.css')">
<body>
<div id="serverData" style="display:none;"></div>
<div id="container">
<h1>
Expand Down
165 changes: 56 additions & 109 deletions data/webapps/cruisecontrol/js/php-under-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,67 @@ Event.observe( window, "load", function() {
);
}

$$(headingSelector).each(collapseTestSuite);
var scrollToFailure = true;

$$( '#phpUnitDetails tbody tr td:first-child' ).each( function( td ) { td.parentNode.hide() } );
$$( '#phpUnitDetails tbody tr > td.failure' ).each(
function( td )
{
td.parentNode.parentNode.select( 'tr' ).each(
function ( tr )
{
tr.show();
if ( scrollToFailure === true )
{
scrollToFailure = false;
tr.scrollTo();
}
}
);
}
);
$$( '#phpUnitDetails tbody tr.phpUnitTestSuite th.phpUnitTestSuiteName' ).each(
function( th ) {
var iconName = 'expanded';
if ( th.parentNode.parentNode.select( 'tr td.failure' ).length === 0 )
{
iconName = 'collapsed';
}

var imagePath = getLinkRootLocation() + '/images/php-under-control/' + iconName + '.png';
th.update( '<img style="display:inline" src="' + imagePath + '" alt=""/>' + th.innerHTML );
th.setStyle( {cursor: 'pointer'} );

var testSuiteIcon = th.firstDescendant();
var testSuite = th.parentNode.parentNode;

Event.observe( th, 'click', function() {
testSuite.select( 'td:first-child' ).each(
function( td )
{
var parentRow = td.parentNode;
if ( parentRow.visible() )
{
testSuiteIcon.setAttribute( 'src', getLinkRootLocation() + '/images/php-under-control/collapsed.png' );
parentRow.hide();
}
else
{
testSuiteIcon.setAttribute( 'src', getLinkRootLocation() + '/images/php-under-control/expanded.png' );
parentRow.show();
}
}
);
} );
}
);
//$$(headingSelector).each(collapseTestSuite);
} );

function callServer( url ) {
document.getElementById('serverData').innerHTML = '<iframe src="' + url + '" width="0" height="0" frameborder="0"></iframe>';
}

function checkIframe(stylesheetURL) {
if (top != self) {//We are being framed!

//For Internet Explorer
if (document.createStyleSheet) {
document.createStyleSheet(stylesheetURL);
}
else { //Non-ie browsers

var styles = "@import url('" + stylesheetURL + "');";

var newSS = document.createElement('link');

newSS.rel = 'stylesheet';

newSS.href = 'data:text/css,' + escape(styles);

document.getElementsByTagName("head")[0].appendChild(newSS);
}
}
}

function over(elem) {
elem.className = 'mouseover';
}
Expand All @@ -65,91 +97,6 @@ function out(elem) {
}

function getLinkRootLocation() {
var location = $$('div#container > h1 > a')[0].getAttribute('href');
var location = $$('#phpUnderControlHeader a')[0].getAttribute('href');
return location.substring(0, location.indexOf('/index'));
}

var headingSelector = "th[colspan=4]";

var scrolledToFailure = false;

var untilNextHeading = function(heading, callback) {
var dataRow = heading.parentNode;
while ((dataRow = dataRow.next()) && dataRow.select(headingSelector).length == 0) {
var td = dataRow.select('td')[0];
if (dataRow.className === "" && $(td).getAttribute('colspan') == 5) {
break;
}
callback(dataRow);
}
}

var getExpanderEventSource = function(evt) {
try {
var element = Event.element(evt);
if (element.nodeName == 'IMG') {
element = element.parentNode;
}
return element;
} catch (e) {
return evt;
}
}

var collapseTestSuite = function(heading) {
heading = getExpanderEventSource(heading);
var signalAttached = false;
var shouldCollapse = true;

untilNextHeading(heading, function(tr) {
var test = tr.select('td')[0];

if (test.hasClassName('error') || test.hasClassName('failure')) {
shouldCollapse = false;
if (scrolledToFailure === false) {
scrolledToFailure = true;
heading.scrollTo();
}
}
});

if (!shouldCollapse) {
expandTestSuite(heading);
return false;
}

untilNextHeading(heading, function(tr) {
tr.hide();

if (!signalAttached) {
heading.parentNode.setStyle({cursor: 'pointer'});
changeExpanderImage(heading, 'collapsed');
heading.parentNode.onclick = expandTestSuite;
}
});
return false;
}

var changeExpanderImage = function(heading, iconName) {
var icon = heading.select('img');
var imagePath = getLinkRootLocation() + '/images/php-under-control/' + iconName + '.png';
if (icon.length > 0) {
$(icon[0]).setAttribute('src', imagePath);
} else {
heading.update('<img style="display:inline" src="' + imagePath + '" alt=""/>' + heading.innerHTML);
}
}

var expandTestSuite = function(heading) {
heading = getExpanderEventSource(heading);
var signalAttached = false;
untilNextHeading(heading, function(tr) {
tr.show();

if (!signalAttached) {
heading.parentNode.onclick = collapseTestSuite;
changeExpanderImage(heading, 'expanded');
}
});
return false;
}
7 changes: 7 additions & 0 deletions data/webapps/cruisecontrol/main.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@
</cruisecontrol:artifactsLink>
</cruisecontrol:tab>
<% } %>

<cruisecontrol:tab name="codeBrowser" label="Code Browser">
<cruisecontrol:artifactsLink>
<iframe src="<%=request.getContextPath() %>/<%= artifacts_url %>/php-code-browser/index.html" class="tab-content">
</iframe>
</cruisecontrol:artifactsLink>
</cruisecontrol:tab>

<%-- phpUnderControl 5 --%>

Expand Down
118 changes: 59 additions & 59 deletions data/webapps/cruisecontrol/xsl/phpunit-details.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -35,62 +35,61 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
********************************************************************************-->
<xsl:output method="html" encoding="UTF-8" indent="yes"/>
<xsl:decimal-format decimal-separator="." grouping-separator="," />
<xsl:output method="html" encoding="UTF-8" indent="yes"/>
<xsl:decimal-format decimal-separator="." grouping-separator="," />

<xsl:variable name="indent.width" select="15" />
<xsl:variable name="indent.width" select="15" />

<!--
Root template
-->
<xsl:template match="/">
<!-- Main table -->
<table id="phpunitDetails" class="result">
<colgroup>
<col width="10%"/>
<col width="45%"/>
<col width="25%"/>
<col width="10%"/>
<col width="10%"/>
</colgroup>
<thead>
<tr>
<th colspan="3">Name</th>
<th>Status</th>
<th nowrap="nowrap">Time(s)</th>
</tr>
</thead>
<tbody>
<!-- display test suites -->
<xsl:apply-templates select="//testsuites/testsuite" />
</tbody>
</table>
</xsl:template>
<!--
Root template
-->
<xsl:template match="/">
<!-- Main table -->
<table id="phpUnitDetails" class="result">
<colgroup>
<col width="10%"/>
<col width="45%"/>
<col width="25%"/>
<col width="10%"/>
<col width="10%"/>
</colgroup>
<thead>
<tr>
<th colspan="3">Name</th>
<th>Status</th>
<th nowrap="nowrap">Time(s)</th>
</tr>
</thead>
<!-- display test suites -->
<xsl:apply-templates select="//testsuites/testsuite" />
</table>
</xsl:template>

<!--
Test Suite Template
Construct TestSuite section
-->
<xsl:template match="testsuite">
<tr><td colspan="5"><br /></td></tr>
<tr>
<xsl:attribute name="class">
<xsl:call-template name="build.result" />
</xsl:attribute>
<th colspan="4">
<xsl:choose>
<xsl:when test="@fullPackage">
<xsl:value-of select="concat(@fullPackage, '::', @name)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@name"/>
</xsl:otherwise>
</xsl:choose>
</th>
<th>
<xsl:value-of select="format-number(@time,'0.000')"/>
</th>
</tr>
<!--
Test Suite Template
Construct TestSuite section
-->
<xsl:template match="testsuite">
<tbody>
<tr>
<xsl:attribute name="class">
<xsl:call-template name="build.result" />
<xsl:text> phpUnitTestSuite</xsl:text>
</xsl:attribute>
<th class="phpUnitTestSuiteName" colspan="4">
<xsl:choose>
<xsl:when test="@fullPackage">
<xsl:value-of select="concat(@fullPackage, '::', @name)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@name"/>
</xsl:otherwise>
</xsl:choose>
</th>
<th class="phpUnitTestSuiteTime">
<xsl:value-of select="format-number(@time,'0.000')"/>
</th>
</tr>

<xsl:variable name="data.provider.prefix" select="concat(@name, '::')" />

Expand All @@ -111,6 +110,7 @@
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</tbody>
</xsl:template>

<!--
Expand Down Expand Up @@ -152,10 +152,10 @@
<xsl:choose>
<xsl:when test="error">
<xsl:choose>
<xsl:when test="error/@type = 'PHPUnit_Framework_SkippedTestError'">
<xsl:when test="error/@type = 'phpUnit_Framework_SkippedTestError'">
<xsl:text>skipped</xsl:text>
</xsl:when>
<xsl:when test="error/@type = 'PHPUnit_Framework_IncompleteTestError'">
<xsl:when test="error/@type = 'phpUnit_Framework_IncompleteTestError'">
<xsl:text>unknown</xsl:text>
</xsl:when>
<xsl:otherwise>
Expand Down Expand Up @@ -185,19 +185,19 @@
<xsl:when test="error">
<xsl:variable name="link.label">
<xsl:choose>
<xsl:when test="error/@type = 'PHPUnit_Framework_SkippedTestError' or
error/@type = 'PHPUnit_Framework_IncompleteTestError'">
<xsl:when test="error/@type = 'phpUnit_Framework_SkippedTestError' or
error/@type = 'phpUnit_Framework_IncompleteTestError'">
<xsl:text>Message</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Error</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a href="#" onclick="$('{$node.id}').toggle()"><xsl:value-of select="$link.label" /> &#187;</a>
<a href="#" onclick="$('{$node.id}').toggle(); return false;"><xsl:value-of select="$link.label" /> &#187;</a>
</xsl:when>
<xsl:when test="failure">
<a href="#" onclick="$('{$node.id}').toggle()">Failure &#187;</a>
<a href="#" onclick="$('{$node.id}').toggle(); return false;">Failure &#187;</a>
</xsl:when>
<xsl:otherwise>Success</xsl:otherwise>
</xsl:choose>
Expand Down
5 changes: 5 additions & 0 deletions src/Commands/ExampleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ protected function doCreateTasks()
{
$tasks[] = new phpucPhpCodeSnifferTask();
}
if ( $this->args === null
|| !$this->args->hasOption( 'without-code-browser' ) )
{
$tasks[] = new phpucCodeBrowserTask();
}
if ( $this->args === null
|| !$this->args->hasOption( 'without-phpunit' ) )
{
Expand Down
Loading

0 comments on commit 95ebad4

Please sign in to comment.