Alexander Nicolaysen Sørnes : test_om_objects: Test unQueue()
Chris Morgan
cmorgan at winehq.org
Wed Jan 23 09:46:06 CST 2008
Module: appdb
Branch: master
Commit: 1f081f4be1e15f9a62d0fd7ae9e89c3e63cae5ee
URL: http://source.winehq.org/git/appdb.git/?a=commit;h=1f081f4be1e15f9a62d0fd7ae9e89c3e63cae5ee
Author: Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
Date: Wed Jan 23 14:18:43 2008 +0100
test_om_objects: Test unQueue()
---
include/application_queue.php | 5 ++++
include/bugs.php | 5 ++++
include/downloadurl.php | 5 ++++
include/maintainer.php | 5 ++++
include/monitor.php | 11 ++++++++++
include/note.php | 10 +++++++++
include/screenshot.php | 5 ++++
include/testData_queue.php | 5 ++++
include/version_queue.php | 5 ++++
unit_test/test_om_objects.php | 45 ++++++++++++++++++++++++++++++++++++++--
10 files changed, 98 insertions(+), 3 deletions(-)
diff --git a/include/application_queue.php b/include/application_queue.php
index 82c8383..5727a28 100644
--- a/include/application_queue.php
+++ b/include/application_queue.php
@@ -259,6 +259,11 @@ class application_queue
return $sErrors;
}
+ function objectGetState()
+ {
+ return $this->oApp->objectGetState();
+ }
+
function canEdit()
{
return $this->oApp->canEdit();
diff --git a/include/bugs.php b/include/bugs.php
index 34cdd5d..a65caa5 100644
--- a/include/bugs.php
+++ b/include/bugs.php
@@ -462,6 +462,11 @@ class Bug
return $sLink;
}
+ function objectGetState()
+ {
+ return ($this->bQueued) ? 'queued' : 'accepted';
+ }
+
function canEdit()
{
if($_SESSION['current']->hasPriv("admin"))
diff --git a/include/downloadurl.php b/include/downloadurl.php
index c4346ef..91c5f47 100644
--- a/include/downloadurl.php
+++ b/include/downloadurl.php
@@ -249,6 +249,11 @@ class downloadurl
return TRUE;
}
+ function objectGetState()
+ {
+ return ($this->bQueued) ? 'queued' : 'accepted';
+ }
+
function canEdit($iVersionId = NULL)
{
if($_SESSION['current']->hasPriv("admin") ||
diff --git a/include/maintainer.php b/include/maintainer.php
index 3449b80..4ad898b 100644
--- a/include/maintainer.php
+++ b/include/maintainer.php
@@ -675,6 +675,11 @@ class maintainer
echo "</td></tr></table></div>\n\n";
}
+ function objectGetState()
+ {
+ return $this->sState;
+ }
+
function canEdit()
{
if($_SESSION['current']->hasPriv("admin") || $this->iUserId == $_SESSION['current']->iUserId)
diff --git a/include/monitor.php b/include/monitor.php
index 7726fb6..afa724d 100644
--- a/include/monitor.php
+++ b/include/monitor.php
@@ -107,6 +107,11 @@ class Monitor {
return TRUE;
}
+ function unQueue()
+ {
+ return true; // We don't queue monitors
+ }
+
function objectGetSubmitterId()
{
return $this->iUserId;
@@ -226,6 +231,12 @@ class Monitor {
mail_appdb($sEmail, $sSubject ,$sMsg);
}
+ function objectGetState()
+ {
+ // We don't queue monitors
+ return 'accepted';
+ }
+
function canEdit()
{
if($_SESSION['current']->hasPriv("admin") ||
diff --git a/include/note.php b/include/note.php
index 0535a9e..b5a7a9e 100644
--- a/include/note.php
+++ b/include/note.php
@@ -77,6 +77,11 @@ class Note {
}
+ function unQueue()
+ {
+ return true; // We don't queue notes
+ }
+
/**
* Update note.
* Returns true on success and false on failure.
@@ -372,6 +377,11 @@ class Note {
return $sLink;
}
+ function objectGetState()
+ {
+ return 'accepted'; // We don't queue notes
+ }
+
// users can edit the note if they:
// - have "admin" privileges
// - maintain the version, or supermaintain the application that
diff --git a/include/screenshot.php b/include/screenshot.php
index b0c6ca2..6838814 100644
--- a/include/screenshot.php
+++ b/include/screenshot.php
@@ -665,6 +665,11 @@ class screenshot
return appData::objectGetHeader("screenshot");
}
+ function objectGetState()
+ {
+ return ($this->bQueued) ? 'queued' : 'accepted';
+ }
+
function canEdit()
{
if($this)
diff --git a/include/testData_queue.php b/include/testData_queue.php
index e08f756..7831015 100644
--- a/include/testData_queue.php
+++ b/include/testData_queue.php
@@ -122,6 +122,11 @@ class testData_queue
return $this->oTestData->checkOutputEditorInput($aClean);
}
+ function objectGetState()
+ {
+ return $this->oTestData->objectGetState();
+ }
+
function canEdit()
{
return $this->oTestData->canEdit();
diff --git a/include/version_queue.php b/include/version_queue.php
index c29916b..08e9a69 100644
--- a/include/version_queue.php
+++ b/include/version_queue.php
@@ -205,6 +205,11 @@ class version_queue
return $sErrors;
}
+ function objectGetState()
+ {
+ return $this->oVersion->objectGetState();
+ }
+
function canEdit()
{
return $this->oVersion->canEdit();
diff --git a/unit_test/test_om_objects.php b/unit_test/test_om_objects.php
index 404100f..26c2081 100644
--- a/unit_test/test_om_objects.php
+++ b/unit_test/test_om_objects.php
@@ -121,6 +121,30 @@ function test_class($sClassName, $aTestMethods)
echo "PASSED\t\t$sClassName::$sMethod\n";
break;
+ case 'unQueue':
+ $bSuccess = true;
+ $oTestObject = create_object($sClassName, $oUser, false);
+
+ $oUser->addPriv('admin');
+ $oTestObject->unQueue();
+
+ $iReceived = $oTestObject->objectGetState();
+ $iExpected = 'accepted';
+ if($iReceived != $iExpected)
+ {
+ error("Got queue state of $iReceived instead of $iExpected\n");
+ error("FAILED\t\t$sClassName::$sMethod");
+ $bSuccess = false;
+ }
+ cleanup($oTestObject);
+ $oTestObject->purge();
+ $oUser->delPriv('admin');
+
+ if(!$bSuccess)
+ return $bSuccess;
+
+ echo "PASSED\t\t$sClassName::$sMethod\n";
+ break;
}
}
@@ -159,9 +183,11 @@ function cleanup($oObject)
}
}
-function create_object($sClassName, $oUser)
+function create_object($sClassName, $oUser, $bAsAdmin = true)
{
- $oUser->addPriv("admin");
+ if($bAsAdmin)
+ $oUser->addPriv("admin");
+
$oTestObject = new $sClassName();
/* Set up one test entry, depending on class */
switch($sClassName)
@@ -188,7 +214,15 @@ function create_object($sClassName, $oUser)
$oTestObject->iVersionId = create_version_and_parent_app("create_object_downloadurl");
break;
case "maintainer":
+ /* We create the version as admin anyway to avoid the maintainer entry getting a state of 'pending' */
+ if(!$bAsAdmin)
+ $oUser->addPriv('admin');
+
$iVersionId = create_version_and_parent_app("create_object_maintainer");
+
+ if(!$bAsAdmin)
+ $oUser->delPriv('admin');
+
$oVersion = new version($iVersionId);
$oTestObject->iUserId = $oUser->iUserId;
$oTestObject->iAppId = $oVersion->iAppId;
@@ -242,6 +276,9 @@ function create_object($sClassName, $oUser)
$oTestObject->iScreenshotId = query_appdb_insert_id();
}
+ if($bAsAdmin)
+ $oUser->delPriv('admin');
+
return $oTestObject;
}
@@ -260,12 +297,14 @@ function test_object_methods()
"objectGetId",
"objectGetMail",
"objectGetMailOptions",
+ 'objectGetState',
"objectGetSubmitterId",
"objectGetTableRow",
"objectMakeLink",
"objectMakeUrl",
"outputEditor",
- "purge"
+ 'purge',
+ 'unQueue'
);
$aTestClasses = array("application",
More information about the wine-cvs
mailing list