Eliminate redundant parameters from testData function

This commit is contained in:
Chris Morgan
2006-07-10 15:42:00 +00:00
committed by WineHQ
parent cd5a620d88
commit 0d8de67fd9
2 changed files with 39 additions and 33 deletions

View File

@@ -38,7 +38,7 @@ class testData{
if($hResult = query_parameters($sQuery, $iTestingId)) if($hResult = query_parameters($sQuery, $iTestingId))
{ {
$oRow = mysql_fetch_object($hResult); $oRow = mysql_fetch_object($hResult);
$this->iTestingId = $iTestingId; $this->iTestingId = $oRow->testingId;
$this->iVersionId = $oRow->versionId; $this->iVersionId = $oRow->versionId;
$this->sWhatWorks = $oRow->whatWorks; $this->sWhatWorks = $oRow->whatWorks;
$this->sWhatDoesnt = $oRow->whatDoesnt; $this->sWhatDoesnt = $oRow->whatDoesnt;
@@ -348,38 +348,20 @@ class testData{
mail_appdb($sEmail, $sSubject ,$sMsg); mail_appdb($sEmail, $sSubject ,$sMsg);
} }
function ShowTestResult($iCurrentTest,$iVersionId) function ShowTestResult()
{ {
$hResult = query_parameters("SELECT *
FROM testResults
WHERE testingId = '?'",
$iCurrentTest);
if(!$hResult || mysql_num_rows($hResult) == 0)
{
$hResult = query_parameters("SELECT *
FROM testResults
WHERE versionId = '?'
ORDER BY testedDate DESC ;",
$iVersionId);
if(!$hResult || mysql_num_rows($hResult) == 0)
return false;
}
$oRow = mysql_fetch_object($hResult);
echo '<p><b>What works</b><br />',"\n"; echo '<p><b>What works</b><br />',"\n";
echo $oRow->whatWorks; echo $this->sWhatWorks;
echo '<p><b>What does not</b><br />',"\n"; echo '<p><b>What does not</b><br />',"\n";
echo $oRow->whatDoesnt; echo $this->sWhatDoesnt;
echo '<p><b>What was not tested</b><br />',"\n"; echo '<p><b>What was not tested</b><br />',"\n";
echo $oRow->whatNotTested; echo $this->sWhatNotTested;
return $oRow->testingId;
} }
// Show the Test results for a application version // Show the Test results for a application version
function ShowVersionsTestingTable($iVersionId, $iCurrentTest, $link, $iDisplayLimit) function ShowVersionsTestingTable($link, $iDisplayLimit)
{ {
/* escape input parameters */ /* escape input parameters */
$iVersionId = mysql_real_escape_string($iVersionId);
$iCurrentTest = mysql_real_escape_string($iCurrentTest);
$link = mysql_real_escape_string($link); $link = mysql_real_escape_string($link);
$iDisplayLimit = mysql_real_escape_string($iDisplayLimit); $iDisplayLimit = mysql_real_escape_string($iDisplayLimit);
@@ -390,7 +372,7 @@ class testData{
$sQuery = "SELECT * $sQuery = "SELECT *
FROM testResults FROM testResults
WHERE versionId = '".$iVersionId."' WHERE versionId = '".$this->iVersionId."'
ORDER BY testedDate DESC"; ORDER BY testedDate DESC";
if(!$showAll) if(!$showAll)
@@ -427,7 +409,9 @@ class testData{
$bgcolor = $oTest->sTestedRating; $bgcolor = $oTest->sTestedRating;
echo '<tr class='.$bgcolor.'>',"\n"; echo '<tr class='.$bgcolor.'>',"\n";
if ($oTest->iTestingId == $iCurrentTest) /* if the test we are displaying is this test then */
/* mark it as the current test */
if ($oTest->iTestingId == $this->iTestingId)
{ {
echo ' <td align="center" class="color2"><b>Current</b></td>',"\n"; echo ' <td align="center" class="color2"><b>Current</b></td>',"\n";
} else } else
@@ -474,7 +458,7 @@ class testData{
echo '</table>',"\n"; echo '</table>',"\n";
echo '<form method=get action="'.$PHP_SELF.'">'; echo '<form method=get action="'.$PHP_SELF.'">';
echo '<input name="iVersionId" type=hidden value="',$iVersionId,'" />'; echo '<input name="iVersionId" type=hidden value="',$this->iVersionId,'" />';
if($rowsUsed >= $iDisplayLimit && !is_string($showAll)) if($rowsUsed >= $iDisplayLimit && !is_string($showAll))
echo '<input class="button" name="showAll" type=submit value="Show All Tests" />'; echo '<input class="button" name="showAll" type=submit value="Show All Tests" />';
@@ -485,6 +469,19 @@ class testData{
echo '</form>'; echo '</form>';
} }
/* retrieve the latest test result for a given version id */
function get_test_for_versionid($iVersionId)
{
$sQuery = "SELECT testingId from testResults where versionId = '?'
ORDER BY testedDate DESC limit 1";
$hResult = query_parameters($sQuery, $iVersionId);
if(!$hResult)
return 0;
$oRow = mysql_fetch_object($hResult);
return $oRow->testingId;
}
// show the fields for editing // show the fields for editing
function OutputEditor($sDistribution="", $bNewDist=false) function OutputEditor($sDistribution="", $bNewDist=false)
{ {

View File

@@ -782,14 +782,23 @@ class Version {
echo "<table width='100%' border=0><tr><td width='100%' valign=top> <b>Description</b><br />\n"; echo "<table width='100%' border=0><tr><td width='100%' valign=top> <b>Description</b><br />\n";
echo $this->sDescription; echo $this->sDescription;
// Show testing data // Show testing data
$oTest = new TestData($iTestingId);
$iCurrentTest = $oTest->ShowTestResult($oTest->iTestingId, $this->iVersionId); $oTest = new testData($iTestingId);
if($iCurrentTest)
/* if $iTestingId wasn't valid then it won't be valid in $oTest */
if(!$oTest->iTestingId)
{ {
$oTest->ShowVersionsTestingTable($this->iVersionId, /* fetch a new testing id for this version */
$iCurrentTest, $iTestingId = testData::get_test_for_versionid($this->iVersionId);
$_SERVER['PHP_SELF']."?iVersionId=".$this->iVersionId."&iTestingId=", $oTest = new testData($iTestingId);
}
$oTest->ShowTestResult();
if($oTest->iTestingId)
{
$oTest->ShowVersionsTestingTable($_SERVER['PHP_SELF']."?iVersionId=".$this->iVersionId."&iTestingId=",
5); 5);
} }
echo '<form method=post name=sMessage action=testResults.php?sSub=view&iVersionId='.$this->iVersionId.'>'; echo '<form method=post name=sMessage action=testResults.php?sSub=view&iVersionId='.$this->iVersionId.'>';