version: Add and use aTestResults member

This commit is contained in:
Alexander Nicolaysen Sørnes
2007-10-25 11:10:32 +02:00
committed by Chris Morgan
parent 729df377f9
commit 69d584ed85
2 changed files with 33 additions and 16 deletions

View File

@@ -34,6 +34,9 @@ class version {
var $iSubmitterId; var $iSubmitterId;
var $sQueued; var $sQueued;
var $sLicense; var $sLicense;
var $aTestResults; /* Array of test result objects. Especially useful when
we want to preview a version before submitting it;
in that case there is no data in the database */
var $iObsoleteBy; /* Whether this version is marked as obsolete, and if so which var $iObsoleteBy; /* Whether this version is marked as obsolete, and if so which
version its votes should be moved to. */ version its votes should be moved to. */
var $iMaintainerRequest; /* Temporary variable for version submisson. var $iMaintainerRequest; /* Temporary variable for version submisson.
@@ -46,6 +49,7 @@ class version {
*/ */
public function Version($iVersionId = null, $oRow = null) public function Version($iVersionId = null, $oRow = null)
{ {
$this->aTestResults = array(); // should always be an array
// we are working on an existing version // we are working on an existing version
if(!$iVersionId && !$oRow) if(!$iVersionId && !$oRow)
return; return;
@@ -755,14 +759,13 @@ class version {
return TRUE; return TRUE;
} }
/* $oTest can be passed by version_queue to allow previewing a version, in which case the test id may not be defined */ public function display($aVars = array())
public function display($aVars, $oTest = null)
{ {
/* is this user supposed to view this version? */ /* is this user supposed to view this version? */
if(!$_SESSION['current']->canViewVersion($this)) if(!$_SESSION['current']->canViewVersion($this))
util_show_error_page_and_exit("Something went wrong with the application or version id"); util_show_error_page_and_exit("Something went wrong with the application or version id");
$iTestingId = $aVars['iTestingId']; $iTestingId = $aVars['iTestingId'] ? $aVars['iTestingId'] : 0;
$oApp = new Application($this->iAppId); $oApp = new Application($this->iAppId);
@@ -983,16 +986,17 @@ class version {
echo "\t\tSelected test results <small><small>(selected in 'Test Results' table below)</small></small>\n"; echo "\t\tSelected test results <small><small>(selected in 'Test Results' table below)</small></small>\n";
echo "\t</div>\n"; echo "\t</div>\n";
/* oTest may be passed by version_queue to allow previewing a version which does not exist in the database */ /* Set if the use chose to display a particular test report */
if(!$oTest && $iTestingId) if($iTestingId)
$oTest = new testData($iTestingId); $oTest = new testData($iTestingId);
else if($this->iVersionId) /* Let's query for the latest rest report */
/* if $iTestingId wasn't valid then it won't be valid in $oTest */
if(!$oTest)
{ {
/* fetch a new test id for this version */
$iTestingId = testData::getNewestTestIdFromVersionId($this->iVersionId); $iTestingId = testData::getNewestTestIdFromVersionId($this->iVersionId);
$oTest = new testData($iTestingId); $oTest = new testData($iTestingId);
} else /* Perhaps we have a cached entry? There should be */
{
$aTests = $this->getTestResults();
$oTest = $aTests[0];
} }
echo "<div class='info_contents'>\n"; echo "<div class='info_contents'>\n";
@@ -1577,9 +1581,14 @@ class version {
"From that page you can edit, delete or approve it into the AppDB.</p>\n"; "From that page you can edit, delete or approve it into the AppDB.</p>\n";
} }
public function objectGetChildren() public function getTestResults()
{ {
$aChildren = array(); /* If we don't have an id we can query the database, but perhaps we
have some cached entries? */
if(!$this->iVersionId)
return $this->aTestResults;
$aTests = array();
/* Find test results */ /* Find test results */
$sQuery = "SELECT * FROM testResults WHERE versionId = '?'"; $sQuery = "SELECT * FROM testResults WHERE versionId = '?'";
@@ -1589,8 +1598,17 @@ class version {
return FALSE; return FALSE;
while($oRow = mysql_fetch_object($hResult)) while($oRow = mysql_fetch_object($hResult))
$aTests[] = new testData(0, $oRow);
return $aTests;
}
public function objectGetChildren()
{
$aChildren = array();
foreach($this->getTestResults() as $oTest)
{ {
$oTest = new testData(0, $oRow);
$aChildren += $oTest->objectGetChildren(); $aChildren += $oTest->objectGetChildren();
$aChildren[] = $oTest; $aChildren[] = $oTest;
} }

View File

@@ -222,10 +222,9 @@ class version_queue
function display() function display()
{ {
$aVars = array(); /* Cache the test result object as it's not in the DB */
$aVars['iTestingId'] = 0; $this->oVersion->aTestResults[] = $this->oTestDataQueue->oTestData;
$this->oVersion->display();
$this->oVersion->display($aVars, $this->oTestDataQueue->oTestData);
} }
function objectMakeUrl() function objectMakeUrl()