Cleanup objectManager tests so all objects created during the test are deleted
This commit is contained in:
committed by
WineHQ
parent
6221e9b921
commit
051a1e5d0c
@@ -302,6 +302,7 @@ class downloadurl
|
|||||||
$this->sUrl, downloadurl::canEdit($this->iVersionId) ?
|
$this->sUrl, downloadurl::canEdit($this->iVersionId) ?
|
||||||
"false" : "true", $_SESSION['current']->iUserId);
|
"false" : "true", $_SESSION['current']->iUserId);
|
||||||
|
|
||||||
|
$this->iId = mysql_insert_id();
|
||||||
if(!$hResult)
|
if(!$hResult)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ $watermark = new Image("/images/watermark.png");
|
|||||||
/**
|
/**
|
||||||
* Screenshot class for handling screenshots and thumbnails
|
* Screenshot class for handling screenshots and thumbnails
|
||||||
*/
|
*/
|
||||||
class Screenshot {
|
class screenshot {
|
||||||
var $iScreenshotId;
|
var $iScreenshotId;
|
||||||
|
|
||||||
// parameters necessary for creating a new screenshot with
|
// parameters necessary for creating a new screenshot with
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ define("LICENSE_RETAIL", "Retail");
|
|||||||
/**
|
/**
|
||||||
* Version class for handling versions.
|
* Version class for handling versions.
|
||||||
*/
|
*/
|
||||||
class Version {
|
class version {
|
||||||
var $iVersionId;
|
var $iVersionId;
|
||||||
var $iAppId;
|
var $iAppId;
|
||||||
var $sName;
|
var $sName;
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ function test_class($sClassName, $aTestMethods)
|
|||||||
$oObject = new ObjectManager("");
|
$oObject = new ObjectManager("");
|
||||||
$oObject->sClass = $sClassName;
|
$oObject->sClass = $sClassName;
|
||||||
|
|
||||||
$iAppId = 65555;
|
|
||||||
|
|
||||||
/* Check whether the required methods are present */
|
/* Check whether the required methods are present */
|
||||||
if(!$oObject->checkMethods($aTestMethods, false))
|
if(!$oObject->checkMethods($aTestMethods, false))
|
||||||
{
|
{
|
||||||
@@ -36,7 +34,7 @@ function test_class($sClassName, $aTestMethods)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Test the class constructor */
|
/* Test the class constructor */
|
||||||
if(!$oTestObject = create_object($sClassName, $oUser, $iAppId))
|
if(!$oTestObject = create_object($sClassName, $oUser))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Should return 1 or more, since there may be entries present already */
|
/* Should return 1 or more, since there may be entries present already */
|
||||||
@@ -106,10 +104,9 @@ function test_class($sClassName, $aTestMethods)
|
|||||||
|
|
||||||
echo "PASSED\t\t$sClassName::$sClassName\n";
|
echo "PASSED\t\t$sClassName::$sClassName\n";
|
||||||
|
|
||||||
|
cleanup($oTestObject);
|
||||||
$oTestObject->delete();
|
$oTestObject->delete();
|
||||||
|
|
||||||
cleanup($sClassName, $iAppId);
|
|
||||||
|
|
||||||
/* Test the methods' functionality */
|
/* Test the methods' functionality */
|
||||||
foreach($aTestMethods as $sMethod)
|
foreach($aTestMethods as $sMethod)
|
||||||
{
|
{
|
||||||
@@ -118,14 +115,13 @@ function test_class($sClassName, $aTestMethods)
|
|||||||
/* Should also test for queued entries, but vendor does not support
|
/* Should also test for queued entries, but vendor does not support
|
||||||
queueing yet */
|
queueing yet */
|
||||||
case "objectGetEntries":
|
case "objectGetEntries":
|
||||||
if(!$oTestObject = create_object($sClassName, $oUser, $iAppId))
|
if(!$oTestObject = create_object($sClassName, $oUser))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Should return 1 or more, since there may be entries present already */
|
/* Should return 1 or more, since there may be entries present already */
|
||||||
$iExpected = 1;
|
$iExpected = 1;
|
||||||
$hResult = $oTestObject->objectGetEntries(false, false);
|
$hResult = $oTestObject->objectGetEntries(false, false);
|
||||||
$iReceived = mysql_num_rows($hResult);
|
$iReceived = mysql_num_rows($hResult);
|
||||||
$oTestObject->delete();
|
|
||||||
if($iExpected > $iReceived)
|
if($iExpected > $iReceived)
|
||||||
{
|
{
|
||||||
echo "Got $iReceived instead of >= $iExpected\n";
|
echo "Got $iReceived instead of >= $iExpected\n";
|
||||||
@@ -135,7 +131,8 @@ function test_class($sClassName, $aTestMethods)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Class specific clean-up */
|
/* Class specific clean-up */
|
||||||
cleanup($sClassName, $iAppId);
|
cleanup($oTestObject);
|
||||||
|
$oTestObject->delete();
|
||||||
|
|
||||||
echo "PASSED\t\t$sClassName::$sMethod\n";
|
echo "PASSED\t\t$sClassName::$sMethod\n";
|
||||||
break;
|
break;
|
||||||
@@ -148,18 +145,50 @@ function test_class($sClassName, $aTestMethods)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup($sClassName, $iAppId)
|
function cleanup($oObject)
|
||||||
{
|
{
|
||||||
switch($sClassName)
|
switch(get_class($oObject))
|
||||||
{
|
{
|
||||||
|
case "downloadurl":
|
||||||
case "maintainer":
|
case "maintainer":
|
||||||
$oApp = new application($iAppId);
|
case "screenshot":
|
||||||
|
case "testData":
|
||||||
|
delete_parent($oObject->iVersionId);
|
||||||
|
break;
|
||||||
|
case "testData_queue":
|
||||||
|
delete_parent($oObject->oTestData->iVersionId);
|
||||||
|
break;
|
||||||
|
case "version":
|
||||||
|
$oApp = new application($oObject->iAppId);
|
||||||
|
$oApp->delete();
|
||||||
|
break;
|
||||||
|
case "version_queue":
|
||||||
|
$oApp = new application($oObject->oVersion->iAppId);
|
||||||
$oApp->delete();
|
$oApp->delete();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_object($sClassName, $oUser, $iAppId)
|
function create_version()
|
||||||
|
{
|
||||||
|
$oApp = new application();
|
||||||
|
$oApp->sName = "OM App";
|
||||||
|
$oApp->create();
|
||||||
|
$oVersion = new version();
|
||||||
|
$oVersion->sName = "OM version";
|
||||||
|
$oVersion->iAppId = $oApp->iAppId;
|
||||||
|
$oVersion->create();
|
||||||
|
return $oVersion->iVersionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_parent($iVersionId)
|
||||||
|
{
|
||||||
|
$oVersion = new version($iVersionId);
|
||||||
|
$oApp = new application($oVersion->iAppId);
|
||||||
|
$oApp->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_object($sClassName, $oUser)
|
||||||
{
|
{
|
||||||
$oUser->addPriv("admin");
|
$oUser->addPriv("admin");
|
||||||
$oTestObject = new $sClassName();
|
$oTestObject = new $sClassName();
|
||||||
@@ -173,22 +202,34 @@ function create_object($sClassName, $oUser, $iAppId)
|
|||||||
case "downloadurl":
|
case "downloadurl":
|
||||||
$oTestObject->sUrl = "http://appdb.winehq.org/";
|
$oTestObject->sUrl = "http://appdb.winehq.org/";
|
||||||
$oTestObject->sDescription = "DANGER";
|
$oTestObject->sDescription = "DANGER";
|
||||||
$oTestObject->iVersionId = 65000; // Just needs to be != 0
|
$oTestObject->iVersionId = create_version();
|
||||||
break;
|
break;
|
||||||
case "maintainer":
|
case "maintainer":
|
||||||
$oApp = new application();
|
$oVersion = new version(create_version());
|
||||||
|
|
||||||
if(!$oApp->create())
|
|
||||||
{
|
|
||||||
echo "Failed to create application";
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
$oApp->iAppId = $iAppId;
|
|
||||||
$oApp->update();
|
|
||||||
$oTestObject->iUserId = $oUser->iUserId;
|
$oTestObject->iUserId = $oUser->iUserId;
|
||||||
$oTestObject->iAppId = $iAppId;
|
$oTestObject->iAppId = $oVersion->iAppId;
|
||||||
|
$oTestObject->iVersionId = $oVersion->iVersionId;
|
||||||
$oTestObject->sMaintainReason = "I need it";
|
$oTestObject->sMaintainReason = "I need it";
|
||||||
break;
|
break;
|
||||||
|
case "screenshot":
|
||||||
|
case "testData":
|
||||||
|
$oTestObject->iVersionId = create_version();
|
||||||
|
break;
|
||||||
|
case "testData_queue":
|
||||||
|
$oTestObject->oTestData->iVersionId = create_version();
|
||||||
|
break;
|
||||||
|
case "version":
|
||||||
|
$oApp = new application();
|
||||||
|
$oApp->create();
|
||||||
|
$oTestObject->iAppId = $oApp->iAppId;
|
||||||
|
$oTestObject->sName = "OM Version";
|
||||||
|
break;
|
||||||
|
case "version_queue":
|
||||||
|
$oApp = new application();
|
||||||
|
$oApp->create();
|
||||||
|
$oTestObject->oVersion->iAppId = $oApp->iAppId;
|
||||||
|
$oTestObject->oVersion->sName = "OM Version";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We cannot use screenshot::create() because it requires an image */
|
/* We cannot use screenshot::create() because it requires an image */
|
||||||
@@ -204,7 +245,7 @@ function create_object($sClassName, $oUser, $iAppId)
|
|||||||
$sQuery = "INSERT INTO appData
|
$sQuery = "INSERT INTO appData
|
||||||
(versionId, type, description, queued, submitterId)
|
(versionId, type, description, queued, submitterId)
|
||||||
VALUES('?','?','?','?','?')";
|
VALUES('?','?','?','?','?')";
|
||||||
$hResult = query_parameters($sQuery, 0, "screenshot", "", "false",
|
$hResult = query_parameters($sQuery, $oTestObject->iVersionId, "screenshot", "", "false",
|
||||||
$oUser->iUserId);
|
$oUser->iUserId);
|
||||||
if(!$hResult)
|
if(!$hResult)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user