Add the long awaited 'maintainer notification' system. This system, running from the cron

cleanup scripts, will look for maintainers that have queued entries that the maintainer can
process. If the queued entries aren't processed for X days an email is sent. In X*2 days
another email is sent. After X*3 days the maintainer is stripped of their maintainership as
they aren't really maintaining the application anyway. The hope is that this system lets
maintainers know that they have pending queued entries to process to reduce the pressure on the
appdb admins to handled hundreds of queued entries.
This commit is contained in:
Chris Morgan
2007-07-20 22:24:37 +00:00
committed by WineHQ
parent 1f7298eb24
commit b5a41fba77
9 changed files with 1212 additions and 37 deletions

View File

@@ -16,6 +16,7 @@ $bTestSuccess = true;
include_once("test_user.php");
echo "\n";
include_once("test_query.php");
echo "\n";
include_once("test_image.php");

View File

@@ -7,4 +7,27 @@ function test_start($sFunctionName)
echo $sFunctionName."() starting\n";
}
?>
// create an application and a version of that application
// return the iVersionId of the created version
function create_version_and_parent_app()
{
$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;
}
// delete a version based on the $iVersionId parameter
// and delete its parent application
function delete_version_and_parent_app($iVersionId)
{
$oVersion = new version($iVersionId);
$oApp = new application($oVersion->iAppId);
$oApp->delete();
}
?>

View File

@@ -3,6 +3,12 @@
require_once("path.php");
require_once(BASE.'include/maintainer.php');
// the maintainer notification system tests have been split out
// into another file
include_once("test_maintainer_notify.php");
/* unit tests for maintainer class */
// test that the maintainer count for a given user is accurate for both
@@ -569,6 +575,7 @@ function test_maintainer_getMaintainersForAppIdVersionId()
return TRUE;
}
if(!test_maintainer_getMaintainerCountForUser())
{
echo "test_maintainer_getMaintainerCountForUser() failed!\n";
@@ -625,4 +632,13 @@ if(!test_maintainer_getMaintainersForAppIdVersionId())
echo "test_maintainer_getMaintainersForAppIdVersionId() passed\n";
}
if(!test_maintainer_notifyMaintainersOfQueuedData())
{
echo "test_maintainer_notifyMaintainersOfQueuedData() failed!\n";
$bTestSuccess = false;
} else
{
echo "test_maintainer_notifyMaintainersOfQueuedData() passed\n";
}
?>

View File

@@ -0,0 +1,697 @@
<?php
class notifyContainer
{
var $oUser;
var $oTestData;
var $oMaintainer;
var $iVersionId; // the version created by create_version_and_parent_app()
function notifyContainer($bTestAsMaintainer)
{
$this->__internal_setupQueuedDataForUser($bTestAsMaintainer);
}
function cleanup()
{
$this->oTestData->delete(); // deleted the created testData
$this->oMaintainer->delete(); // delete the created maintainer entry
// (Should be deleted when the user is deleted)
// delete the version and its parent application that we created
delete_version_and_parent_app($this->iVersionId);
// delete the user we created
$this->oUser->delete();
}
//FIXME: this should be private when we get php5
function __internal_setupQueuedDataForUser($bTestAsMaintainer)
{
$bDebugOutputEnabled = false;
$this->oUser = new User();
$sUserEmail = "notifyMaintainerUser@somesite.com";
$sUserPassword = "password";
// if we can login as the user, delete the user
if($this->oUser->login($sUserEmail, $sUserPassword) == SUCCESS)
{
// delete the user and create the new user object
$this->oUser->delete();
$this->oUser = new User();
}
// create the user
$iRetval = $this->oUser->create("notifyMaintainerUser@somesite.com",
"password", "testuser1", "0.1.0");
if($iRetval != SUCCESS)
{
echo "User creation failed, returned $iRetval\n";
}
// flag the testing user as the current user
$_SESSION['current'] = $this->oUser;
// create a fake version
$this->iVersionId = create_version_and_parent_app();
// create a queued entry for the user we just created
$this->oTestData = new testData();
$this->oTestData->iVersionId = $this->iVersionId;
$this->oTestData->shWhatWorks = "nothing";
$this->oTestData->shWhatDoesnt = "nothing";
$this->oTestData->shWhatNotTested = "nothing";
$this->oTestData->sTestedDate = "20070404";
$this->oTestData->sInstalls = "Yes";
$this->oTestData->sRuns = "Yes";
$this->oTestData->sTestedRating = "Gold";
$this->oTestData->sComments = "";
if(!$this->oTestData->create())
{
echo "Failed to create testData\n";
}
// make this testData queued, we need to manually override this
// because the user created the application and version and
// because of this the user is allowed to submit unqueued test data
// for an unqueued version that they created
$this->oTestData->ReQueue();
// refresh the testdata object now that we've modified its queued status
$this->oTestData = new testData($this->oTestData->iTestingId);
if($bDebugOutputEnabled)
{
echo "testData:\n";
print_r($this->oTestData);
}
// NOTE: we don't unqueue $oTestData because maintainer notification
// only applies to queued testData
$this->oVersion = new Version($this->iVersionId);
// make the user a maintainer of the fake version or application
// depending on whether this user is a maintainer or super maintainer
$this->oMaintainer = new maintainer();
$this->oMaintainer->iUserId = $this->oUser->iUserId;
$this->oMaintainer->iAppId = $this->oVersion->iAppId;
$this->oMaintainer->sMaintainReason = "for testing";
if($bTestAsMaintainer) // create a version maintainer entry
{
$this->oMaintainer->bSuperMaintainer = false;
$this->oMaintainer->iVersionId = $this->iVersionId;
} else // create an application maintainer entry, a super maintainer entry
{
$this->oMaintainer->bSuperMaintainer = true;
$this->oMaintainer->iVersionId = 0;
}
if(!$this->oMaintainer->create())
{
echo "Failed to create maintainer!\n";
}
// notification code checks versions of a super maintainers application
// we must unqueue the version. if the version is queued
// we will only process this queued version during notification
// and will skip over queued entries that depend on this version
if(!$bTestAsMaintainer)
{
$sVersionUnqueue = "update appVersion set queued='?' where versionId = '?'";
$hResult = query_parameters($sVersionUnqueue, 'false', $this->iVersionId);
}
// debug printing
if($bDebugOutputEnabled)
{
$sQuery2 = "select * from appMaintainers where maintainerId = '?'";
$hResult = query_parameters($sQuery2, $this->oMaintainer->iMaintainerId);
$oObject = mysql_fetch_object($hResult);
print_r($oObject);
}
// adjust the maintainer submitTime because the oldest entry is
// truncated at the time the user became a maintainer to prevent punishing
// them for signing up for an app that has had queued data for a long time
$iAdjustedTime = strtotime("now") - (100 * 24 * 60 * 60); // 100 days ago
$sQuery = "update appMaintainers set submitTime = '?' where maintainerId = '?'";
$sDate = date('Y-m-d H:i:s', $iAdjustedTime);
query_parameters($sQuery, $sDate, $this->oMaintainer->iMaintainerId);
if($bDebugOutputEnabled)
{
echo "iAdjustedTime for maintainer ".$iAdjustedTime."\n";
echo "iMaintainerId: ".$this->oMaintainer->iMaintainerId."\n";
}
// update our maintainer object to get the new submit time
$this->oMaintainer = new Maintainer($this->oMaintainer->iMaintainerId);
// echo "new maintainer class:\n";
// print_r($this->oMaintainer);
}
// adjust the submission time of the $oTestData object
// to make it appear as if it is $iAgeInSeconds old
function adjustTestDataSubmitTime($iAgeInSeconds)
{
// now adjust the submission time of this entry
// so it is older than iNotificationIntervalDays
// echo "strtotime('now') is ".strtotime("now")."\n";
// echo "iAgeInSeconds is ".$iAgeInSeconds."\n";
$iAdjustedTime = strtotime("now") - $iAgeInSeconds;
$sDate = date('Y-m-d H:i:s', $iAdjustedTime);
$sQuery = "update testResults set submitTime = '?' where testingId = '?'";
query_parameters($sQuery, $sDate, $this->oTestData->iTestingId);
// debug printing
// echo "iAdjustedTime is ".$iAdjustedTime."\n";
// echo "Original date is: ".date('Y-m-d H:i:s', strtotime("now"))."\n";
// echo "New date is ".$sDate."\n";
}
// returns true if the level is correct, false if not
function checkLevel($iExpectedLevel)
{
$bSuccess = true;
// create a new maintainer so we can check its level, we COULD use
// the level of the existing $oMaintainer object but we want to
// check both to make sure that the $oMaintainer was updated
// AND that the database was updated
$oMaintainer2 = new maintainer($this->oMaintainer->iMaintainerId);
// print_r($this->oMaintainer);
if($this->oMaintainer->iNotificationLevel != $iExpectedLevel)
{
echo "oMaintainer expected iNotificationLevel of ".$iExpectedLevel.
", actual level is ".$this->oMaintainer->iNotificationLevel."\n";
$bSuccess = false;
}
// echo "maintainer2\n";
// print_r($oMaintainer2);
if($oMaintainer2->iNotificationLevel != $iExpectedLevel)
{
echo "oMaintainer2 expected iNotificationLevel of ".$iExpectedLevel.
", actual level is ".$oMaintainer2->iNotificationLevel."\n";
$bSuccess = false;
}
return $bSuccess;
}
}
// test a user going from nothing(level 0) to level 1
function test_maintainer_notifyLevel_0_to_1($bTestAsMaintainer)
{
echo __FUNCTION__."\n";
$bSuccess = true; // default to success
$oNotifyContainer = new notifyContainer($bTestAsMaintainer);
// adjust the test data submit time back a little bit
// to be in the level 1 range
$iSecondsOlder = ((iNotificationIntervalDays + 1) * 24 * 60 * 60);
$oNotifyContainer->adjustTestDataSubmitTime($iSecondsOlder);
// run the notification code to update the users level
$oNotifyContainer->oMaintainer->notifyMaintainerOfQueuedData();
$bSuccess = $oNotifyContainer->checkLevel(1);
if(!$bSuccess)
echo "checkLevel() failed\n";
// cleanup the things we created during the notification test
$oNotifyContainer->cleanup();
return $bSuccess;
}
// test a user going from level 1 to level 2, so the queued time is
// >= (iNotificationIntervalDays * 2)
function test_maintainer_notifyLevel_1_to_2($bTestAsMaintainer)
{
echo __FUNCTION__."\n";
$bSuccess = true; // default to success
$oNotifyContainer = new notifyContainer($bTestAsMaintainer);
// adjust the test data submit time back two intervals + 1 day
// this should be in the level 2 range
$iSecondsOlder = (((iNotificationIntervalDays * 2) + 1) * 24 * 60 * 60);
$oNotifyContainer->adjustTestDataSubmitTime($iSecondsOlder);
// update the maintainers level to be level 1 to begin with and have them be
// notified iNotificationIntervalDays + 1 ago because we don't check the user
// again unless it has been more thatn iNotificationIntervalDays since
// the last check
$iAdjustedTime = strtotime("now") - ((iNotificationIntervalDays + 1) * 24 * 60 * 60);
$sDate = date('Y-m-d H:i:s', $iAdjustedTime);
$sQuery = "update appMaintainers set notificationLevel = '?', notificationTime = '?' ".
"where maintainerId = '?'";
$iStartingLevel = 1;
query_parameters($sQuery, $iStartingLevel, $sDate,
$oNotifyContainer->oMaintainer->iMaintainerId);
// update the maintainer class so our manual changes take effect
$oNotifyContainer->oMaintainer = new Maintainer($oNotifyContainer->oMaintainer->iMaintainerId);
// run the notification code to update the users level
$oNotifyContainer->oMaintainer->notifyMaintainerOfQueuedData();
$bSuccess = $oNotifyContainer->checkLevel(2);
if(!$bSuccess)
echo "checkLevel() failed\n";
// cleanup the things we created during the notification test
$oNotifyContainer->cleanup();
return $bSuccess;
}
// test user going from level 2 to 3, where the user will be deleted
function test_maintainer_notifyLevel_2_to_3($bTestAsMaintainer)
{
echo __FUNCTION__."\n";
$bSuccess = true; // default to success
$oNotifyContainer = new notifyContainer($bTestAsMaintainer);
// adjust the test data submit time back three intervals + 1 day
// this should be in the level 3 range
$iSecondsOlder = (((iNotificationIntervalDays * 3) + 1) * 24 * 60 * 60);
$oNotifyContainer->adjustTestDataSubmitTime($iSecondsOlder);
// update the maintainers level to be level 2 to begin with and have them be
// notified iNotificationIntervalDays + 1 ago
// update the maintainers level to be level 1 to begin with and have them be
// notified iNotificationIntervalDays + 1 ago because we don't check the user
// again unless it has been more thatn iNotificationIntervalDays since
// the last check
$iAdjustedTime = strtotime("now") - ((iNotificationIntervalDays + 1) * 24 * 60 * 60);
$sDate = date('Y-m-d H:i:s', $iAdjustedTime);
$sQuery = "update appMaintainers set notificationLevel = '?', ".
"notificationTime = '?' where maintainerId = '?'";
$iStartingLevel = 2;
query_parameters($sQuery, $iStartingLevel, $sDate,
$oNotifyContainer->oMaintainer->iMaintainerId);
// update the maintainer class so our manual changes take effect
$oNotifyContainer->oMaintainer = new Maintainer($oNotifyContainer->oMaintainer->iMaintainerId);
// run the notification code to update the users level
$oNotifyContainer->oMaintainer->notifyMaintainerOfQueuedData();
// check to make sure the maintainer doesn't exist
$sQuery = "select count(*) as cnt from appMaintainers where maintainerId = '?'";
$hResult = query_parameters($sQuery, $oNotifyContainer->oMaintainer->iMaintainerId);
$oRow = mysql_fetch_object($hResult);
if($oRow->cnt != 0)
{
$bSuccess = false;
}
// cleanup the things we created during the notification test
$oNotifyContainer->cleanup();
return $bSuccess;
}
// test user going from level 2 to level 1
function test_maintainer_notifyLevel_2_to_1($bTestAsMaintainer)
{
echo __FUNCTION__."\n";
$bSuccess = true; // default to success
$oNotifyContainer = new notifyContainer($bTestAsMaintainer);
// adjust the test data submit time back one interval + 1 day
// this should be in the level 1 range
$iSecondsOlder = ((iNotificationIntervalDays + 1) * 24 * 60 * 60);
$oNotifyContainer->adjustTestDataSubmitTime($iSecondsOlder);
// update the maintainers level to be level 2 to begin with and have them be
// notified iNotificationIntervalDays + 1 ago
// update the maintainers level to be level 1 to begin with and have them be
// notified iNotificationIntervalDays + 1 ago because we don't check the user
// again unless it has been more thatn iNotificationIntervalDays since
// the last check
$iAdjustedTime = strtotime("now") - ((iNotificationIntervalDays + 1) * 24 * 60 * 60);
$sDate = date('Y-m-d H:i:s', $iAdjustedTime);
$sQuery = "update appMaintainers set notificationLevel = '?', notificationTime = '?' ".
"where maintainerId = '?'";
$iStartingLevel = 2;
query_parameters($sQuery, $iStartingLevel, $sDate,
$oNotifyContainer->oMaintainer->iMaintainerId);
// update the maintainer class so our manual changes take effect
$oNotifyContainer->oMaintainer = new Maintainer($oNotifyContainer->oMaintainer->iMaintainerId);
// run the notification code to update the users level
$oNotifyContainer->oMaintainer->notifyMaintainerOfQueuedData();
$bSuccess = $oNotifyContainer->checkLevel(1);
if(!$bSuccess)
echo "checkLevel() failed\n";
// cleanup the things we created during the notification test
$oNotifyContainer->cleanup();
return $bSuccess;
}
// test user going from level 1 to level 0
function test_maintainer_notifyLevel_1_to_0($bTestAsMaintainer)
{
echo __FUNCTION__."\n";
$bSuccess = true; // default to success
$oNotifyContainer = new notifyContainer($bTestAsMaintainer);
// this is only a few seconds old
$iSecondsOlder = 60;
$oNotifyContainer->adjustTestDataSubmitTime($iSecondsOlder);
// update the maintainers level to be level 1 to begin with and have them be
// notified iNotificationIntervalDays + 1 ago
// update the maintainers level to be level 1 to begin with and have them be
// notified iNotificationIntervalDays + 1 ago because we don't check the user
// again unless it has been more thatn iNotificationIntervalDays since
// the last check
$iAdjustedTime = strtotime("now") - ((iNotificationIntervalDays + 1) * 24 * 60 * 60);
$sDate = date('Y-m-d H:i:s', $iAdjustedTime);
$sQuery = "update appMaintainers set notificationLevel = '?', notificationTime = '?' ".
"where maintainerId = '?'";
$iStartingLevel = 1;
query_parameters($sQuery, $iStartingLevel, $sDate,
$oNotifyContainer->oMaintainer->iMaintainerId);
// update the maintainer class so our manual changes take effect
$oNotifyContainer->oMaintainer = new Maintainer($oNotifyContainer->oMaintainer->iMaintainerId);
// run the notification code to update the users level
$oNotifyContainer->oMaintainer->notifyMaintainerOfQueuedData();
$bSuccess = $oNotifyContainer->checkLevel(0);
if(!$bSuccess)
echo "checkLevel() failed\n";
// cleanup the things we created during the notification test
$oNotifyContainer->cleanup();
return $bSuccess;
}
// test user going from level 2 to level 0
function test_maintainer_notifyLevel_2_to_0($bTestAsMaintainer)
{
echo __FUNCTION__."\n";
$bSuccess = true; // default to success
$oNotifyContainer = new notifyContainer($bTestAsMaintainer);
// this is only a few seconds old
$iSecondsOlder = 60;
$oNotifyContainer->adjustTestDataSubmitTime($iSecondsOlder);
// update the maintainers level to be level 1 to begin with and have them be
// notified iNotificationIntervalDays + 1 ago
// update the maintainers level to be level 1 to begin with and have them be
// notified iNotificationIntervalDays + 1 ago because we don't check the user
// again unless it has been more thatn iNotificationIntervalDays since
// the last check
$iAdjustedTime = strtotime("now") - ((iNotificationIntervalDays + 1) * 24 * 60 * 60);
$sDate = date('Y-m-d H:i:s', $iAdjustedTime);
$sQuery = "update appMaintainers set notificationLevel = '?', notificationTime = '?' ".
"where maintainerId = '?'";
$iStartingLevel = 2;
query_parameters($sQuery, $iStartingLevel, $sDate,
$oNotifyContainer->oMaintainer->iMaintainerId);
// update the maintainer class so our manual changes take effect
$oNotifyContainer->oMaintainer = new Maintainer($oNotifyContainer->oMaintainer->iMaintainerId);
// run the notification code to update the users level
$oNotifyContainer->oMaintainer->notifyMaintainerOfQueuedData();
$bSuccess = $oNotifyContainer->checkLevel(0);
if(!$bSuccess)
echo "checkLevel() failed\n";
// cleanup the things we created during the notification test
$oNotifyContainer->cleanup();
return $bSuccess;
}
// test that a user that should go from level 1 to level 2 will not do so
// because the last update time is too soon
function test_maintainer_notifyLevel_1_to_2_delay($bTestAsMaintainer)
{
echo __FUNCTION__."\n";
$bSuccess = true; // default to success
$oNotifyContainer = new notifyContainer($bTestAsMaintainer);
// adjust the test data submit time back two intervals + 1 day
// this should be in the level 2 range
$iSecondsOlder = (((iNotificationIntervalDays * 2) + 1) * 24 * 60 * 60);
$oNotifyContainer->adjustTestDataSubmitTime($iSecondsOlder);
// set the notification time as if we just notified this particular
// maintainer a few seconds ago
$iAdjustedTime = strtotime("now") - 60;
$sDate = date('Y-m-d H:i:s', $iAdjustedTime);
$sQuery = "update appMaintainers set notificationLevel = '?', notificationTime = '?' ".
"where maintainerId = '?'";
$iStartingLevel = 1;
query_parameters($sQuery, $iStartingLevel, $sDate,
$oNotifyContainer->oMaintainer->iMaintainerId);
// update the maintainer class so our manual changes take effect
$oNotifyContainer->oMaintainer = new Maintainer($oNotifyContainer->oMaintainer->iMaintainerId);
// run the notification code to update the users level
$oNotifyContainer->oMaintainer->notifyMaintainerOfQueuedData();
$bSuccess = $oNotifyContainer->checkLevel(1);
if(!$bSuccess)
echo "checkLevel() failed\n";
// cleanup the things we created during the notification test
$oNotifyContainer->cleanup();
return $bSuccess;
}
// test that a user with queued items not old enough to cause a transition
// from level 0 to 1 will remain at level 0
function test_maintainer_notifyLevel_0_to_0($bTestAsMaintainer)
{
echo __FUNCTION__."\n";
$bSuccess = true; // default to success
$oNotifyContainer = new notifyContainer($bTestAsMaintainer);
// adjust the test data submit time back two intervals + 1 day
// this should be in the level 2 range
$iSecondsOlder = 60;
$oNotifyContainer->adjustTestDataSubmitTime($iSecondsOlder);
// flag this maintainer as being notified at least a iNotificationIntervalDays
// ago so they should certainly be notified again
$iAdjustedTime = strtotime("now") - ((iNotificationIntervalDays + 1) * 24 * 60 * 60);
$sDate = date('Y-m-d H:i:s', $iAdjustedTime);
$sQuery = "update appMaintainers set notificationLevel = '?', notificationTime = '?' ".
"where maintainerId = '?'";
$iStartingLevel = 1;
query_parameters($sQuery, $iStartingLevel, $sDate,
$oNotifyContainer->oMaintainer->iMaintainerId);
// update the maintainer class so our manual changes take effect
$oNotifyContainer->oMaintainer = new Maintainer($oNotifyContainer->oMaintainer->iMaintainerId);
// run the notification code to update the users level
$oNotifyContainer->oMaintainer->notifyMaintainerOfQueuedData();
$bSuccess = $oNotifyContainer->checkLevel(0);
if(!$bSuccess)
echo "checkLevel() failed\n";
// cleanup the things we created during the notification test
$oNotifyContainer->cleanup();
return $bSuccess;
}
// test that a user with queued data that is really really old will
// only go from level 0 to level 1
function test_maintainer_notifyLevel_0_to_1_with_old_queued_data($bTestAsMaintainer)
{
echo __FUNCTION__."\n";
$bSuccess = true; // default to success
$oNotifyContainer = new notifyContainer($bTestAsMaintainer);
// adjust the test data submit time back a little bit
// to be in the level 1 range
$iSecondsOlder = (((iNotificationIntervalDays * 5) + 1) * 24 * 60 * 60);
$oNotifyContainer->adjustTestDataSubmitTime($iSecondsOlder);
// run the notification code to update the users level
$oNotifyContainer->oMaintainer->notifyMaintainerOfQueuedData();
$bSuccess = $oNotifyContainer->checkLevel(1);
if(!$bSuccess)
echo "checkLevel() failed\n";
// cleanup the things we created during the notification test
$oNotifyContainer->cleanup();
return $bSuccess;
}
function test_maintainer_notifyLevel_starts_at_zero($bTestAsMaintainer)
{
echo __FUNCTION__."\n";
$bSuccess = true; // default to success
$oNotifyContainer = new notifyContainer($bTestAsMaintainer);
// see if our notification level is zero
if($oNotifyContainer->oMaintainer->iNotificationLevel != 0)
{
$bSuccess = false;
}
$oNotifyContainer->cleanup();
return $bSuccess;
}
// test maintainer::notifyMaintainerOfQueuedData() in various
// potential situations
// $bTestAsMaintainer == true - the user being tested is a normal maintainer
// $bTestAsMaintainer == false - the user being tested is a super maintainer
function _test_maintainer_notifyMaintainersOfQueuedData($bTestAsMaintainer)
{
$bSuccess = true; // default to success
echo __FUNCTION__."\n";
$sFunction = "test_maintainer_notifyLevel_0_to_1";
if(!$sFunction($bTestAsMaintainer))
{
echo $sFunction." failed!\n";
$bSuccess = false;
}
$sFunction = "test_maintainer_notifyLevel_1_to_2";
if(!$sFunction($bTestAsMaintainer))
{
echo $sFunction." failed!\n";
$bSuccess = false;
}
$sFunction = "test_maintainer_notifyLevel_2_to_3";
if(!$sFunction($bTestAsMaintainer))
{
echo $sFunction." failed!\n";
$bSuccess = false;
}
$sFunction = "test_maintainer_notifyLevel_2_to_1";
if(!$sFunction($bTestAsMaintainer))
{
echo $sFunction." failed!\n";
$bSuccess = false;
}
$sFunction = "test_maintainer_notifyLevel_1_to_0";
if(!$sFunction($bTestAsMaintainer))
{
echo $sFunction." failed!\n";
$bSuccess = false;
}
$sFunction = "test_maintainer_notifyLevel_2_to_0";
if(!$sFunction($bTestAsMaintainer))
{
echo $sFunction." failed!\n";
$bSuccess = false;
}
$sFunction = "test_maintainer_notifyLevel_1_to_2_delay";
if(!$sFunction($bTestAsMaintainer))
{
echo $sFunction." failed!\n";
$bSuccess = false;
}
$sFunction = "test_maintainer_notifyLevel_0_to_0";
if(!$sFunction($bTestAsMaintainer))
{
echo $sFunction." failed!\n";
$bSuccess = false;
}
$sFunction = "test_maintainer_notifyLevel_0_to_1_with_old_queued_data";
if(!$sFunction($bTestAsMaintainer))
{
echo $sFunction." failed!\n";
$bSuccess = false;
}
$sFunction = "test_maintainer_notifyLevel_starts_at_zero";
if(!$sFunction($bTestAsMaintainer))
{
echo $sFunction." failed!\n";
$bSuccess = false;
}
return $bSuccess;
}
// test maintainer::notifyMaintainerOfQueuedData() in various
// potential situations
// NOTE: we test one as a normal maintainer and once as a super maintainer
function test_maintainer_notifyMaintainersOfQueuedData()
{
$bSuccess = true;
echo "Testing as maintainer\n";
if(!_test_maintainer_notifyMaintainersOfQueuedData(true))
{
echo "Maintainer test failed!\n";
$bSuccess = false;
}
echo "\n\nTesting as super maintainer\n";
if(!_test_maintainer_notifyMaintainersOfQueuedData(false))
{
echo "Super maintainer test failed!\n";
$bSuccess = false;
}
return $bSuccess;
}
?>

View File

@@ -159,10 +159,10 @@ function cleanup($oObject)
case "maintainer":
case "screenshot":
case "testData":
delete_parent($oObject->iVersionId);
delete_version_and_parent_app($oObject->iVersionId);
break;
case "testData_queue":
delete_parent($oObject->oTestData->iVersionId);
delete_version_and_parent_app($oObject->oTestData->iVersionId);
break;
case "version":
$oApp = new application($oObject->iAppId);
@@ -175,25 +175,6 @@ function cleanup($oObject)
}
}
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");
@@ -208,10 +189,10 @@ function create_object($sClassName, $oUser)
case "downloadurl":
$oTestObject->sUrl = "http://appdb.winehq.org/";
$oTestObject->sDescription = "DANGER";
$oTestObject->iVersionId = create_version();
$oTestObject->iVersionId = create_version_and_parent_app();
break;
case "maintainer":
$oVersion = new version(create_version());
$oVersion = new version(create_version_and_parent_app());
$oTestObject->iUserId = $oUser->iUserId;
$oTestObject->iAppId = $oVersion->iAppId;
$oTestObject->iVersionId = $oVersion->iVersionId;
@@ -219,10 +200,10 @@ function create_object($sClassName, $oUser)
break;
case "screenshot":
case "testData":
$oTestObject->iVersionId = create_version();
$oTestObject->iVersionId = create_version_and_parent_app();
break;
case "testData_queue":
$oTestObject->oTestData->iVersionId = create_version();
$oTestObject->oTestData->iVersionId = create_version_and_parent_app();
break;
case "version":
$oApp = new application();