Unit test cleanups. Fixes tests so they don't leave left over entries in the database. Add a

check to ensure that row counts in most tables are unchanged from the start and end of the
tests. Refactor some code.
This commit is contained in:
Chris Morgan
2007-07-26 03:47:34 +00:00
committed by WineHQ
parent 0b979fee68
commit 19f6cbc156
16 changed files with 505 additions and 244 deletions

View File

@@ -165,7 +165,7 @@ function cmd_send_passwd()
$oUser = new User($iUserId);
if ($iUserId)
{
if ($oUser->update_password($sPasswd))
if ($oUser->update_password($sPasswd))
{
$sSubject = "Application DB Lost Password";
$sMsg = "We have received a request that you lost your password.\r\n";

View File

@@ -231,6 +231,8 @@ class Application {
*/
function delete($bSilent=false)
{
$bSuccess = true;
/* make sure the current user has the appropriate permission to delete
this application */
if(!$_SESSION['current']->canDeleteApplication($this))
@@ -246,10 +248,10 @@ class Application {
{
$iVersionId = $oRow->versionId;
$oVersion = new Version($iVersionId);
$oVersion->delete($bSilent);
if(!$oVersion->delete($bSilent))
$bSuccess = false; // return false, deleting the version failed
}
/* fetch urlsIds */
$aUrlsIds = array();
$sQuery = "SELECT id
@@ -289,7 +291,7 @@ class Application {
if(!$bSilent)
$this->SendNotificationMail("delete");
return true;
return $bSuccess;
}

View File

@@ -229,10 +229,9 @@ class downloadurl
function canEdit($iVersionId = NULL)
{
$oUser = new User($_SESSION['current']->iUserId);
if($oUser->hasPriv("admin") || ($iVersionId &&
maintainer::isUserMaintainer($oUser, $iVersionId)))
if($_SESSION['current']->hasPriv("admin") ||
($iVersionId &&
maintainer::isUserMaintainer($_SESSION['current'], $iVersionId)))
{
return TRUE;
} else

View File

@@ -128,6 +128,8 @@ class screenshot
/**
* Deletes the screenshot from the database.
* and request its deletion from the filesystem (including the thumbnail).
*
* Returns: true if deletion was success, false if otherwise
*/
function delete($bSilent=false)
{
@@ -155,6 +157,8 @@ class screenshot
{
$this->mailSubmitter(true);
}
return true;
}
function reject()

View File

@@ -5,6 +5,9 @@
/* TODO: test the rest of the classes we have */
require_once("path.php");
require_once(BASE.'include/incl.php');
error_reporting(E_ALL);
// disable emailing
@@ -14,6 +17,11 @@ if(!defined("DISABLE_EMAIL"))
// default to the tests being successful
$bTestSuccess = true;
// retrieve counts of each of the tables so we can check again
// at the end of the
$oStartingTableCounts = new table_counts();
include_once("test_user.php");
echo "\n";
@@ -35,6 +43,23 @@ include_once("test_appData.php");
echo "\n";
include_once("test_testData.php");
// retrieve counts of each of the tables after our tests
$oEndingTableCounts = new table_counts();
// see if our table counts match
if(!$oEndingTableCounts->IsEqual($oStartingTableCounts))
{
$bTestSuccess = false;
echo "\n\nStarting and ending table counts do not match\n";
$oStartingTableCounts->OutputSideBySide($oEndingTableCounts,
"Starting",
"Ending");
} else
{
echo "\n\nTable counts match from the start and end of the test suite.\n";
}
if($bTestSuccess == true)
{
echo "\nAll tests were successful\n";
@@ -42,4 +67,107 @@ if($bTestSuccess == true)
{
echo "\nSome test(s) failed!\n";
}
// keep track of the counts of various tables
class table_counts
{
// the tables we should count, set in the constructor
var $aTablesToCount;
// the counts of the tables
var $aTableCounts;
function table_counts()
{
$this->aTablesToCount = array('appBundle',
'appCategory',
'appComments',
'appData',
'appFamily',
'appMaintainers',
'appMonitors',
'appNotes',
'appVersion',
'appVotes',
'buglinks',
'distributions',
'prefs_list',
'testResults',
'user_list',
'user_privs',
'vendor');
$this->update_counts();
}
// update the count for each table
function update_counts()
{
$this->aTableCounts = array();
foreach($this->aTablesToCount as $sTable)
{
$sQuery = "select count(*) as cnt from ?;";
$hResult = query_parameters($sQuery, $sTable);
$oRow = mysql_fetch_object($hResult);
$this->aTableCounts[] = $oRow->cnt;
}
}
// returns 'true' if equal, 'false' if not
function IsEqual($oTableCounts)
{
$iIndex = 0;
for($iIndex = 0; $iIndex < count($this->aTableCounts); $iIndex++)
{
if($this->aTableCounts[$iIndex] != $oTableCounts->aTableCounts[$iIndex])
{
return false;
}
}
return true;
}
function OutputSideBySide($oTableCounts, $sFirstTableCountName,
$sSecondTableCountName)
{
$iIndex = 0;
// output the header
printf("%20s%20s%20s\n",
"Table name",
$sFirstTableCountName,
$sSecondTableCountName);
for($iIndex = 0; $iIndex < count($this->aTableCounts); $iIndex++)
{
printf("%20s%20s%20s",
$this->aTablesToCount[$iIndex],
$this->aTableCounts[$iIndex],
$oTableCounts->aTableCounts[$iIndex]);
if($this->aTableCounts[$iIndex] != $oTableCounts->aTableCounts[$iIndex])
{
echo " <-- Mismatch";
}
echo "\n";
}
}
function output()
{
$iIndex = 0;
for($iIndex = 0; $iIndex < count($this->aTableCounts); $iIndex++)
{
$sTableName = $this->aTablesToCount[$iIndex];
$iTableCount = $this->aTableCounts[$iIndex];
echo "$sTableName count of $iTableCount\n";
}
}
}
?>

View File

@@ -7,12 +7,15 @@ require_once(BASE."include/downloadurl.php");
function test_appData_listSubmittedBy()
{
$bSuccess = true;
test_start(__FUNCTION__);
global $test_email, $test_password;
if(!$oUser = create_and_login_user())
$sTestEmail = __FUNCTION__."@localhost.com";
$sTestPassword = "password";
if(!$oUser = create_and_login_user($sTestEmail, $sTestPassword))
{
echo "Failed to create and log in user\n";
error("Failed to create and log in user");
return FALSE;
}
@@ -35,17 +38,20 @@ function test_appData_listSubmittedBy()
$iReceived = substr_count($shReturn, "</tr>");
if($iExpected != $iReceived)
{
echo "Got $iReceived rows instead of $iExpected.\n";
$oDownloadUrl->delete();
$oUser->delete();
return FALSE;
error("Got $iReceived rows instead of $iExpected.");
$bSuccess = false;
}
/* Clean up */
$oDownloadUrl->delete();
if(!$oDownloadUrl->delete())
{
$bSuccess = false;
error("Failed to delete oDownloadUrl!");
}
$oUser->delete();
return TRUE;
return $bSuccess;
}
if(!test_appData_listSubmittedBy())

View File

@@ -5,9 +5,7 @@ require_once(BASE.'include/maintainer.php');
require_once(BASE.'include/user.php');
require_once(BASE.'include/version.php');
require_once(BASE.'include/application.php');
$test_email = "testemail@somesite.com";
$test_password = "password";
require_once("test_common.php");
/* test that Application::delete() properly deletes data dependent on */
/* having an application */
@@ -17,7 +15,10 @@ function test_application_delete()
{
test_start(__FUNCTION__);
if(!$oUser = create_and_login_user())
$sTestEmail = "test_application_delete@somesite.com";
$sTestPassword = "password";
if(!$oUser = create_and_login_user($sTestEmail, $sTestPassword))
return false;
/* make this user an admin so we can create applications without having them queued */
@@ -31,7 +32,7 @@ function test_application_delete()
if(!$oApp->create())
{
$oUser->delete(); /* clean up the user we created prior to exiting */
echo "Failed to create application!\n";
error("Failed to create application!");
return false;
}
@@ -78,7 +79,10 @@ function test_application_getWithRating()
{
test_start(__FUNCTION__);
if(!$oUser = create_and_login_user())
$sTestEmail = "test_application_getwithrating@somesite.com";
$sTestPassword = "password";
if(!$oUser = create_and_login_user($sTestEmail, $sTestPassword))
return false;
/* make this user an admin so we can create applications without having them queued */
@@ -92,7 +96,7 @@ function test_application_getWithRating()
if(!$oApp->create())
{
$oUser->delete();
echo "Failed to create application!\n";
error("Failed to create application!");
return false;
}
@@ -126,7 +130,7 @@ function test_application_getWithRating()
if(!$oVersion->create())
{
delete_app_and_user($oApp, $oUser);
echo "Failed to create version!\n";
error("Failed to create version!");
return false;
}
}
@@ -142,7 +146,7 @@ function test_application_getWithRating()
if ( in_array($iId, $aTest) ) //if the appId is already in our test results fail unique test
{
delete_app_and_user($oApp, $oUser);
echo "getWithRating failed to return a unique result set\n";
error("getWithRating failed to return a unique result set");
return false;
}
@@ -156,8 +160,9 @@ function test_application_getWithRating()
//test to ensure getWithRating doesn't return applications that are queued
if(!$oUser = create_and_login_user()) //create user without admin priveliges
return false;
//create user without admin priveliges
if(!$oUser = create_and_login_user($sTestEmail, $sTestPassword))
return false;
$oApp = new Application();
@@ -167,7 +172,7 @@ function test_application_getWithRating()
if(!$oApp->create())
{
$oUser->delete(); /* clean up the user we created prior to exiting */
echo "Failed to create application!\n";
error("Failed to create application!");
return false;
}
@@ -183,7 +188,7 @@ function test_application_getWithRating()
if(!$oVersion->create())
{
delete_app_and_user($oApp, $oUser);
echo "Failed to create version!\n";
error("Failed to create version!");
return false;
}
@@ -193,7 +198,7 @@ function test_application_getWithRating()
if ( in_array($iAppId, $aApps )) //if the appId is in our test results fail queued test
{
delete_app_and_user($oApp, $oUser);
echo "getWithRating failed to return a unique result set\n";
error("getWithRating failed to return a unique result set");
return false;
}
@@ -202,50 +207,22 @@ function test_application_getWithRating()
return true;
}
function delete_app_and_user($oApp, $oUser)
{
$oApp->delete();
$oUser->delete();
}
function create_and_login_user()
{
global $test_email, $test_password;
$oUser = new User();
/* delete the user if they already exist */
if($oUser->login($test_email, $test_password) == SUCCESS)
$bSuccess = true;
if(!$oApp->delete())
{
$oUser->delete();
$oUser = new User();
echo __FUNCTION__."() oApp->delete() failed\n";
$bSuccess = false;
}
/* create the user */
$retval = $oUser->create("$test_email", "$test_password", "Test user", "20051020");
if($retval != SUCCESS)
if(!$oUser->delete())
{
if($retval == USER_CREATE_EXISTS)
echo "The user already exists!\n";
else if($retval == USER_LOGIN_FAILED)
echo "User login failed!\n";
else
echo "ERROR: UNKNOWN ERROR!!\n";
return false;
echo __FUNCTION__."() oUser->delete() failed\n";
$bSuccess = false;
}
/* login the user */
$retval = $oUser->login($test_email, $test_password);
if($retval != SUCCESS)
{
echo "Got '".$retval."' instead of SUCCESS(".SUCCESS.")\n";
return false;
}
return $oUser;
return $bSuccess;
}
if(!test_application_delete())

View File

@@ -9,13 +9,13 @@ function test_start($sFunctionName)
// create an application and a version of that application
// return the iVersionId of the created version
function create_version_and_parent_app()
function create_version_and_parent_app($sId = "")
{
$oApp = new application();
$oApp->sName = "OM App";
$oApp->sName = "OM App ".$sId;
$oApp->create();
$oVersion = new version();
$oVersion->sName = "OM version";
$oVersion->sName = "OM version ".$sId;
$oVersion->iAppId = $oApp->iAppId;
$oVersion->create();
return $oVersion->iVersionId;
@@ -23,11 +23,80 @@ function create_version_and_parent_app()
// delete a version based on the $iVersionId parameter
// and delete its parent application
// NOTE: we enable admin permissions here to ensure that
// the application and version are deleted
function delete_version_and_parent_app($iVersionId)
{
$bWasAdmin = $_SESSION['current']->hasPriv("admin");
$_SESSION['current']->addPriv("admin");
$oVersion = new version($iVersionId);
$oApp = new application($oVersion->iAppId);
$oApp->delete();
if(!$oApp->delete())
{
echo __FUNCTION__."() oApp->delete() failed, returned false!\n";
}
// remove the admin privleges only if the user didn't
// have them to begin with
if(!$bWasAdmin)
$_SESSION['current']->delPriv("admin");
}
function create_and_login_user($sTestEmail, $sTestPassword)
{
$oUser = new User();
/* delete the user if they already exist */
if($oUser->login($sTestEmail, $sTestPassword) == SUCCESS)
{
$oUser->delete();
$oUser = new User();
}
/* create the user */
$retval = $oUser->create($sTestEmail, $sTestPassword, "Test user", "20051020");
if($retval != SUCCESS)
{
if($retval == USER_CREATE_EXISTS)
error("The user already exists!");
else if($retval == USER_LOGIN_FAILED)
error("User login failed!");
else
error("ERROR: UNKNOWN ERROR!!");
return false;
}
/* login the user */
$retval = $oUser->login($sTestEmail, $sTestPassword);
if($retval != SUCCESS)
{
error("Got '".$retval."' instead of SUCCESS(".SUCCESS.")");
return false;
}
return $oUser;
}
function error($sMsg)
{
$aBT = debug_backtrace();
// get class, function called by caller of caller of caller
if(isset($aBT[1]['class']))
$sClass = $aBT[1]['class'];
else
$sClass = "";
$sFunction = $aBT[1]['function'];
// get file, line where call to caller of caller was made
$sFile = $aBT[0]['file'];
$sLine = $aBT[0]['line'];
// build & return the message
echo "$sClass::$sFunction:$sFile:$sLine $sMsg\n";
}
?>

View File

@@ -26,7 +26,7 @@ function test_filter()
$sResult = filter_gpc();
if(!$sResult)
{
echo "filter_gpc() succeeded when it should have failed due to invalid input!\n";
error("filter_gpc() succeeded when it should have failed due to invalid input!");
return false;
}
@@ -44,20 +44,20 @@ function test_filter()
$sResult = filter_gpc();
if($sResult)
{
echo "sResult is '$sResult' but we expected success and no return value\n";
error("sResult is '$sResult' but we expected success and no return value");
return false;
}
// make sure the values match what we expect
if($aClean['sString'] != $sString)
{
echo "Expected aClean['sString'] to be '".$sString."' but instead it was '".$aClean['sString']."'\n";
error("Expected aClean['sString'] to be '".$sString."' but instead it was '".$aClean['sString']."'");
return false;
}
if($aClean['iInteger'] != $iInteger)
{
echo "Expected aClean['iInteger'] to be '".$iInteger."' but instead it was '".$aClean['iInteger']."'\n";
error("Expected aClean['iInteger'] to be '".$iInteger."' but instead it was '".$aClean['iInteger']."'");
return false;
}
@@ -73,14 +73,14 @@ function test_filter()
$sResult = filter_gpc();
if($sResult)
{
echo "sResult is '$sResult' but we expected success and no return value\n";
error("sResult is '$sResult' but we expected success and no return value");
return false;
}
// expect that the filtered value will be equal
if($aClean['shHtml'] != $shHtml)
{
echo "Expected aClean['shHtml'] to be '".$shHtml."' but instead it was '".$aClean['shHtml']."'\n";
error("Expected aClean['shHtml'] to be '".$shHtml."' but instead it was '".$aClean['shHtml']."'");
return false;
}
@@ -96,7 +96,7 @@ function test_filter()
$sResult = filter_gpc();
if($sResult)
{
echo "sResult is '$sResult' but we expected success and no return value\n";
error("sResult is '$sResult' but we expected success and no return value");
return false;
}
@@ -104,18 +104,17 @@ function test_filter()
// shouldn't be equal unless something has failed
if($aClean['sHtml'] == $sHtml)
{
echo "Expected aClean['shHtml'] to be '".$sHtml."' but instead it was '".$aClean['sHtml']."'\n";
error("Expected aClean['shHtml'] to be '".$sHtml."' but instead it was '".$aClean['sHtml']."'");
return false;
}
// make sure all html has been stripped
if(strip_tags($aClean['sHtml']) != $aClean['sHtml'])
{
echo "Expected all html to be stripped already but we were able to strip this '".$aClean['sHtml']
."' into '".strip_tags($aClean['sHtml'])."'\n";
error("Expected all html to be stripped already but we were able to strip this '".$aClean['sHtml']
."' into '".strip_tags($aClean['sHtml'])."'");
return false;
}
return true;
}

View File

@@ -22,21 +22,21 @@ function test_image_constructor()
if(!$oImage->isLoaded())
{
echo "Error, unable to load image filename of ".$sImageFilename."\n";
echo "Internal filename is: ".$oImage->sFile."\n";
error("Error, unable to load image filename of ".$sImageFilename);
error("Internal filename is: ".$oImage->sFile);
return false;
}
/* make sure the image size is correct */
if($oImage->get_width() != TEST_IMAGE_WIDTH)
{
echo "Expected width of ".TEST_IMAGE_WIDTH.", got ".$oImage->get_width()."\n";
error("Expected width of ".TEST_IMAGE_WIDTH.", got ".$oImage->get_width());
return false;
}
if($oImage->get_height() != TEST_IMAGE_HEIGHT)
{
echo "Expected width of ".TEST_IMAGE_HEIGHT.", got ".$oImage->get_height()."\n";
error("Expected width of ".TEST_IMAGE_HEIGHT.", got ".$oImage->get_height());
return false;
}
@@ -45,7 +45,7 @@ function test_image_constructor()
$oImage = new Image("somefilethatdoesntexist.png");
if($oImage->isLoaded())
{
echo "Error, isLoaded() returned true for a image that doesn't exist, expected false!\n";
error("Error, isLoaded() returned true for a image that doesn't exist, expected false!");
return false;
}
@@ -63,8 +63,8 @@ function test_image_make_thumbnail()
if(!$oImage->isLoaded())
{
echo "Error, unable to load image filename of ".$sImageFilename."\n";
echo "Internal filename is: ".$oImage->sFile."\n";
error("Error, unable to load image filename of ".$sImageFilename);
error("Internal filename is: ".$oImage->sFile);
return false;
}
@@ -79,16 +79,16 @@ function test_image_make_thumbnail()
$iActualWidth = $oImage->get_width();
if($iActualWidth != $iWidth)
{
echo "Expected width of $iWidth, got ".$iActualWidth."\n";
echo $oImage->get_debuglog(false);
error("Expected width of $iWidth, got ".$iActualWidth);
error($oImage->get_debuglog(false));
return false;
}
$iActualHeight = $oImage->get_height();
if($iActualHeight != $iHeight)
{
echo "Expected height of $iHeight, got ".$iActualHeight."\n";
echo $oImage->get_debuglog(false);
error("Expected height of $iHeight, got ".$iActualHeight);
error($oImage->get_debuglog(false));
return false;
}
@@ -106,8 +106,8 @@ function test_image_make_full()
if(!$oImage->isLoaded())
{
echo "Error, unable to load image filename of ".$sImageFilename."\n";
echo "Internal filename is: ".$oImage->sFile."\n";
error("Error, unable to load image filename of ".$sImageFilename);
error("Internal filename is: ".$oImage->sFile);
return false;
}
@@ -123,16 +123,16 @@ function test_image_make_full()
$iActualWidth = $oImage->get_width();
if($iActualWidth != $iWidth)
{
echo "Expected width of $iWidth, got ".$iActualWidth."\n";
echo $oImage->get_debuglog(false);
error("Expected width of $iWidth, got ".$iActualWidth);
error($oImage->get_debuglog(false));
return false;
}
$iActualHeight = $oImage->get_height();
if($iActualHeight != $iHeight)
{
echo "Expected height of $iHeight, got ".$iActualHeight."\n";
echo $oImage->get_debuglog(false);
error("Expected height of $iHeight, got ".$iActualHeight);
error($oImage->get_debuglog(false));
return false;
}
@@ -150,15 +150,15 @@ function test_image_output_to_file()
if(!$oImage->isLoaded())
{
echo "Error, unable to load image filename of ".$sImageFilename."\n";
echo "Internal filename is: ".$oImage->sFile."\n";
error("Error, unable to load image filename of ".$sImageFilename);
error("Internal filename is: ".$oImage->sFile);
return false;
}
/* write the file to disk */
if(!$oImage->output_to_file(TEST_IMAGE_OUTPUT_FILENAME))
{
echo "image::output_to_file failed to output to filename of ".TEST_IMAGE_OUTPUT_FILENAME."\n";
error("image::output_to_file failed to output to filename of ".TEST_IMAGE_OUTPUT_FILENAME);
return false;
}
@@ -166,8 +166,8 @@ function test_image_output_to_file()
$oImage2 = new Image(TEST_IMAGE_OUTPUT_FILENAME, true);
if(!$oImage2->isLoaded())
{
echo "Error, unable to load newly output image filename of ".TEST_IMAGE_OUTPUT_FILENAME."\n";
echo "Internal filename is: ".$oImage2->sFile."\n";
error("Error, unable to load newly output image filename of ".TEST_IMAGE_OUTPUT_FILENAME);
error("Internal filename is: ".$oImage2->sFile);
return false;
}
@@ -178,9 +178,9 @@ function test_image_output_to_file()
$oImage2 = new Image(TEST_IMAGE_OUTPUT_FILENAME, true);
if($oImage2->isLoaded())
{
echo "Error, unlinking filename of ".TEST_IMAGE_OUTPUT_FILENAME." failed, we are able to\n";
echo " open up a file that should have been deleted.\n";
echo "Internal filename is: ".$oImage2->sFile."\n";
error("Error, unlinking filename of ".TEST_IMAGE_OUTPUT_FILENAME." failed, we are able to");
error(" open up a file that should have been deleted.");
error("Internal filename is: ".$oImage2->sFile);
return false;
}
@@ -198,8 +198,8 @@ function test_image_add_watermark()
if(!$oImage->isLoaded())
{
echo "Error, unable to load image filename of ".$sImageFilename."\n";
echo "Internal filename is: ".$oImage->sFile."\n";
error("Error, unable to load image filename of ".$sImageFilename);
error("Internal filename is: ".$oImage->sFile);
return false;
}
@@ -207,8 +207,8 @@ function test_image_add_watermark()
$oWatermark = new Image(TEST_IMAGE_WATERMARK);
if(!$oWatermark->isLoaded())
{
echo "Error, unable to load image filename of ".TEST_IMAGE_WATERMARK."\n";
echo "Internal filename is: ".$oWatermark->sFile."\n";
error("Error, unable to load image filename of ".TEST_IMAGE_WATERMARK);
error("Internal filename is: ".$oWatermark->sFile);
return false;
}

View File

@@ -18,15 +18,12 @@ function test_maintainer_getMaintainerCountForUser()
{
test_start(__FUNCTION__);
global $test_email, $test_password;
/* login the user */
$oUser = new User();
$retval = $oUser->login($test_email, $test_password);
if($retval != SUCCESS)
$sTestEmail = __FUNCTION__."@localhost.com";
$sTestPassword = "password";
if(!($oUser = create_and_login_user($sTestEmail, $sTestPassword)))
{
echo "Got '".$retval."' instead of SUCCESS(".SUCCESS.")\n";
return false;
error("Failed to create and log in user!");
return FALSE;
}
/**
@@ -52,7 +49,8 @@ function test_maintainer_getMaintainerCountForUser()
$iSuperMaintainerCount = Maintainer::getMaintainerCountForUser($oUser, TRUE);
if($iSuperMaintainerCount != $iExpected)
{
echo "Got super maintainer count of '".$iSuperMaintainerCount."' instead of '".$iExpected."'\n";
error("Got super maintainer count of '".$iSuperMaintainerCount."' instead of '".$iExpected."'");
$oUser->delete();
return false;
}
@@ -61,7 +59,8 @@ function test_maintainer_getMaintainerCountForUser()
$iMaintainerCount = Maintainer::getMaintainerCountForUser($oUser, FALSE);
if($iMaintainerCount != $iExpected)
{
echo "Got maintainer count of '".$iMaintainerCount."' instead of '".$iExpected."'\n";
error("Got maintainer count of '".$iMaintainerCount."' instead of '".$iExpected."'");
$oUser->delete();
return false;
}
@@ -89,7 +88,8 @@ function test_maintainer_getMaintainerCountForUser()
$iSuperMaintainerCount = Maintainer::getMaintainerCountForUser($oUser, TRUE);
if($iSuperMaintainerCount != $iExpected)
{
echo "Got super maintainer count of '".$iSuperMaintainerCount."' instead of '".$iExpected."'\n";
error("Got super maintainer count of '".$iSuperMaintainerCount."' instead of '".$iExpected."'");
$oUser->delete();
return false;
}
@@ -98,13 +98,15 @@ function test_maintainer_getMaintainerCountForUser()
$iMaintainerCount = Maintainer::getMaintainerCountForUser($oUser, FALSE);
if($iMaintainerCount != $iExpected)
{
echo "Got maintainer count of '".$iMaintainerCount."' instead of '".$iExpected."'\n";
error("Got maintainer count of '".$iMaintainerCount."' instead of '".$iExpected."'");
$oUser->delete();
return false;
}
/* remove maintainership for this user */
Maintainer::deleteMaintainer($oUser, $iAppId, $iVersionId);
$oUser->delete();
return true;
}
@@ -114,15 +116,12 @@ function test_maintainer_getAppsMaintained()
{
test_start(__FUNCTION__);
global $test_email, $test_password;
/* login the user */
$oUser = new User();
$retval = $oUser->login($test_email, $test_password);
if($retval != SUCCESS)
$sTestEmail = __FUNCTION__."@localhost.com";
$sTestPassword = "password";
if(!($oUser = create_and_login_user($sTestEmail, $sTestPassword)))
{
echo "Got '".$retval."' instead of SUCCESS(".SUCCESS.")\n";
return false;
error("Failed to create and log in user!");
return FALSE;
}
/* make this user an admin so we can create applications without having them queued */
@@ -136,7 +135,8 @@ function test_maintainer_getAppsMaintained()
$oApp->submitterId = $oUser->iUserId;
if(!$oApp->create())
{
echo "Failed to create application!\n";
error("Failed to create application!");
$oUser->delete();
return false;
}
@@ -164,7 +164,8 @@ function test_maintainer_getAppsMaintained()
if(!$aAppsMaintained)
{
echo "aAppsMaintained is null, we expected a non-null return value!\n";
error("aAppsMaintained is null, we expected a non-null return value!");
$oUser->delete();
return false;
}
@@ -175,19 +176,22 @@ function test_maintainer_getAppsMaintained()
/* make sure all parameters match what we added as maintainer information */
if($iAppId1 != $iAppId)
{
echo "Expected iAppid of ".$iAppId." but got ".$iAppId1."\n";
error("Expected iAppid of ".$iAppId." but got ".$iAppId1);
$oUser->delete();
return false;
}
if($iVersionId1 != $iVersionId)
{
echo "Expected iVersionId of ".$iVersionId." but got ".$iVersionId1."\n";
error("Expected iVersionId of ".$iVersionId." but got ".$iVersionId1);
$oUser->delete();
return false;
}
if($bSuperMaintainer1 != $bSuperMaintainer)
{
echo "Expected bSuperMaintainer of ".$bSuperMaintainer." but got ".$bSuperMaintainer1."\n";
error("Expected bSuperMaintainer of ".$bSuperMaintainer." but got ".$bSuperMaintainer1);
$oUser->delete();
return false;
}
@@ -198,6 +202,8 @@ function test_maintainer_getAppsMaintained()
$oApp = new Application($iAppId);
$oApp->delete();
$oUser->delete();
return true;
}
@@ -206,17 +212,31 @@ function test_maintainer_unQueue()
{
test_start(__FUNCTION__);
global $test_email, $test_password;
/* login the user */
$oFirstUser = new User();
$retval = $oFirstUser->login($test_email, $test_password);
if($retval != SUCCESS)
$sTestEmail = __FUNCTION__."@localhost.com";
$sTestPassword = "password";
if(!($oFirstUser = create_and_login_user($sTestEmail, $sTestPassword)))
{
echo "Got '".$retval."' instead of SUCCESS(".SUCCESS.")\n";
return false;
error("Failed to create and log in first user!");
return FALSE;
}
// create a second user
$sTestEmail = __FUNCTION__."2nd@localhost.com";
$sTestPassword = "password";
if(!($oSecondUser = create_and_login_user($sTestEmail, $sTestPassword)))
{
error("Failed to create and log in second user!");
$oFirstUser->delete();
return FALSE;
}
// make the first user the current user
// because create_and_login_user() calls user::login()
// and this sets $_SESSION['current'] so we need
// to override the create_and_login_user() for the second user
$_SESSION['current'] = $oFirstUser;
$iAppId = 655000;
$iVersionId = 655200;
@@ -224,8 +244,7 @@ function test_maintainer_unQueue()
$oVersion = new Version();
$oApp->iAppId = $iAppId;
$oVersion->iVersionId = $iVersionId;
$oSecondUser = new User();
$oSecondUser->iUserId = $_SESSION['current']->iUserId + 1;
/* Create a non-super maintainer for a different userId; it should not be affected
by the other user first becoming a maintainer and then a super maintainer of
the same application */
@@ -235,7 +254,10 @@ function test_maintainer_unQueue()
$oSecondUserMaintainer->iUserId = $oSecondUser->iUserId;
$oSecondUserMaintainer->sMaintainReason = "I need it";
$oSecondUserMaintainer->bSuperMaintainer = FALSE;
$oSecondUserMaintainer->create();
if(!$oSecondUserMaintainer->create())
error("oSecondUserMaintainer->create() failed");
$oSecondUserMaintainer->unQueue();
/* Create a super maintainer for a different userId; it should not be affected
by the other user first becoming a maintainer and then a super maintainer of
@@ -247,10 +269,14 @@ function test_maintainer_unQueue()
$oSecondUserSuperMaintainer->sMaintainReason = "I need it";
$oSecondUserSuperMaintainer->bSuperMaintainer = TRUE;
// disable admin permissions around the creation of the second maintainer
// so the maintainer object remains queued
$oFirstUser->delPriv("admin");
$oSecondUserSuperMaintainer->create();
if(!$oSecondUserSuperMaintainer->create())
error("oSecondUserSuperMaintainer->create() failed");
$oFirstUser->addPriv("admin");
/* Create a non-super maintainer
It should be removed later because a super maintainer entry for the same
application is added */
@@ -260,18 +286,22 @@ function test_maintainer_unQueue()
$oFirstUserMaintainer->iUserId = $_SESSION['current']->iUserId;
$oFirstUserMaintainer->sMaintainReason = "The most stupid reason";
$oFirstUserMaintainer->bSuperMaintainer = FALSE;
$oFirstUserMaintainer->create();
if(!$oFirstUserMaintainer->create())
error("oFirstUserMaintainer->create() failed");
$oFirstUserMaintainer->unQueue("");
$sStatus = $oFirstUserMaintainer->unQueue("");
/* There should now be 1 maintainer and 0 super maintainers */
$iExpected = 1;
$iReceived = maintainer::getMaintainerCountForUser($oFirstUser, FALSE);
if($iExpected != $iReceived)
{
echo "Got maintainer count of $iReceived instead of $iExpected\n";
error("Got maintainer count of $iReceived instead of $iExpected");
error("sStatus is $sStatus");
maintainer::deleteMaintainersForApplication($oApp);
maintainer::deleteMaintainersForVersion($oVersion);
$oFirstUser->delete();
$oSecondUser->delete();
return FALSE;
}
@@ -279,9 +309,11 @@ function test_maintainer_unQueue()
$iReceived = maintainer::getMaintainerCountForUser($oFirstUser, TRUE);
if($iExpected != $iReceived)
{
echo "Got super maintainer count of $iReceived instead of $iExpected\n";
error("Got super maintainer count of $iReceived instead of $iExpected");
maintainer::deleteMaintainersForApplication($oApp);
maintainer::deleteMaintainersForVersion($oVersion);
$oFirstUser->delete();
$oSecondUser->delete();
return FALSE;
}
@@ -295,7 +327,8 @@ function test_maintainer_unQueue()
$oFirstUserSuperMaintainer->iUserId = $_SESSION['current']->iUserId;
$oFirstUserSuperMaintainer->sMaintainReason = "Some crazy reason";
$oFirstUserSuperMaintainer->bSuperMaintainer = TRUE;
$oFirstUserSuperMaintainer->create();
if(!$oFirstUserSuperMaintainer->create())
error("oFirstUserSuperMaintainer->create() failed");
/* and unqueue it to accept the user as a maintainer */
$oFirstUserSuperMaintainer->unQueue("Some reply text");
@@ -309,9 +342,12 @@ function test_maintainer_unQueue()
$iSuperMaintainerCount = maintainer::getMaintainerCountForUser($oFirstUser, TRUE);
if($iSuperMaintainerCount != $iExpected)
{
echo "Got super maintainer count of '".$iSuperMaintainerCount."' instead of '".$iExpected."'\n";
error("Got super maintainer count of '".$iSuperMaintainerCount.
"' instead of '".$iExpected."'");
maintainer::deleteMaintainersForApplication($oApp);
maintainer::deleteMaintainersForVersion($oVersion);
$oFirstUser->delete();
$oSecondUser->delete();
return false;
}
@@ -321,44 +357,53 @@ function test_maintainer_unQueue()
$iMaintainerCount = maintainer::getMaintainerCountForUser($oFirstUser, FALSE);
if($iMaintainerCount != $iExpected)
{
echo "Got maintainer count of '".$iMaintainerCount."' instead of '".$iExpected."'\n";
error("Got maintainer count of '".$iMaintainerCount.
"' instead of '".$iExpected."'");
maintainer::deleteMaintainersForApplication($oApp);
maintainer::deleteMaintainersForVersion($oVersion);
$oFirstUser->delete();
$oSecondUser->delete();
return false;
}
/* Now the maintainer request for the other user should still be present */
/* Now the maintainer entry for the second user should still be present */
$iExpected = 1;
$iReceived = maintainer::getmaintainerCountForUser($oSecondUser, FALSE);
$iReceived = maintainer::getMaintainerCountForUser($oSecondUser, FALSE);
if($iExpected != $iReceived)
{
echo "Got maintainer count of $iReceived instead of $iExpected\n";
error("Got maintainer count of $iReceived instead of $iExpected");
maintainer::deleteMaintainersForApplication($oApp);
maintainer::deleteMaintainersForVersion($oVersion);
$oFirstUser->delete();
$oSecondUser->delete();
return FALSE;
}
/* Now the super maintainer request for the other user should still be present */
// Now the super maintainer request for the second user should still be present
$oSecondUserSuperMaintainer->unQueue();
$iExpected = 1;
$iReceived = maintainer::getmaintainerCountForUser($oSecondUser, TRUE);
$iReceived = maintainer::getMaintainerCountForUser($oSecondUser, TRUE);
if($iExpected != $iReceived)
{
echo "Got super maintainer count of $iReceived instead of $iExpected\n";
error("Got super maintainer count of $iReceived instead of $iExpected");
maintainer::deleteMaintainersForApplication($oApp);
maintainer::deleteMaintainersForVersion($oVersion);
$oFirstUser->delete();
$oSecondUser->delete();
return FALSE;
}
/* Now the maintainer request of the other user should be gone */
$oSecondUserMaintainer->unQueue();
// Now that the super maintainer entry was unqueued the the maintainer
// entry should have been deleted
$iExpected = 0;
$iReceived = maintainer::getmaintainerCountForUser($oSecondUser, FALSE);
$iReceived = maintainer::getMaintainerCountForUser($oSecondUser, FALSE);
if($iExpected != $iReceived)
{
echo "Got maintainer count of $iReceived instead of $iExpected\n";
error("Got maintainer count of $iReceived instead of $iExpected");
maintainer::deleteMaintainersForApplication($oApp);
maintainer::deleteMaintainersForVersion($oVersion);
$oFirstUser->delete();
$oSecondUser->delete();
return FALSE;
}
@@ -366,6 +411,9 @@ function test_maintainer_unQueue()
maintainer::deleteMaintainersForApplication($oApp);
maintainer::deleteMaintainersForVersion($oVersion);
$oFirstUser->delete();
$oSecondUser->delete();
return true;
}
@@ -374,13 +422,11 @@ function test_superMaintainerOnAppSubmit()
{
test_start(__FUNCTION__);
global $test_email, $test_password;
/* Log in */
$oUser = new User();
if($retval = $oUser->login($test_email, $test_password) != SUCCESS)
$sTestEmail = __FUNCTION__."@localhost.com";
$sTestPassword = "password";
if(!($oUser = create_and_login_user($sTestEmail, $sTestPassword)))
{
echo "Received '$retval' instead of SUCCESS('".SUCCESS."').";
error("Failed to create and log in user!");
return FALSE;
}
@@ -408,13 +454,15 @@ function test_superMaintainerOnAppSubmit()
if($iGot != $iExpected)
{
echo "Got maintainer count of '$iGot' instead of '$iExpected'";
error("Got maintainer count of '$iGot' instead of '$iExpected'");
$oUser->delete();
return false;
}
Maintainer::deleteMaintainer($oUser, $iAppId);
$oApp->delete();
$oUser->delete();
return true;
}
@@ -425,10 +473,13 @@ function test_maintainer_deleteMaintainersForVersion()
{
test_start(__FUNCTION__);
global $test_email, $test_password;
$oUser = new user();
$oUser->login($test_email, $test_password);
$sTestEmail = __FUNCTION__."@localhost.com";
$sTestPassword = "password";
if(!($oUser = create_and_login_user($sTestEmail, $sTestPassword)))
{
error("Failed to create and log in user!");
return FALSE;
}
$oMaintainer = new maintainer();
$oMaintainer->iAppId = 655000;
@@ -444,11 +495,13 @@ function test_maintainer_deleteMaintainersForVersion()
if(maintainer::deleteMaintainersForVersion($oVersion) !== FALSE)
{
echo "Got success, but this should fail.\n";
error("Got success, but this should fail.");
$oUser->delete();
return FALSE;
}
$oMaintainer->delete();
$oUser->delete();
return TRUE;
}
@@ -457,16 +510,19 @@ function test_maintainer_getMaintainersForAppIdVersionId()
{
test_start(__FUNCTION__);
global $test_email, $test_password;
$oUser = new user();
if($oUser->login($test_email, $test_password) != SUCCESS)
$sTestEmail = __FUNCTION__."@localhost.com";
$sTestPassword = "password";
if(!($oUser = create_and_login_user($sTestEmail, $sTestPassword)))
{
echo "Failed to create and log in user!\n";
error("Failed to create and log in user!");
return FALSE;
}
$oUser->addPriv("admin");
// assign the user with admin permissions as the current user
$_SESSION['current'] = $oUser;
$oSecondUser = new user();
$oSecondUser->iUserId = $oUser->iUserId + 1;
$oSecondUser->addPriv("admin");
@@ -474,10 +530,12 @@ function test_maintainer_getMaintainersForAppIdVersionId()
$oApp = new application();
$oApp->create();
$oFirstVersion = new version();
$oFirstVersion->iAppId = $oApp->iAppId;
$oFirstVersion->sName = __FUNCTION__." first version";
$oFirstVersion->iAppId = $oApp->iAppId; // $oApp is the parent
$oFirstVersion->create();
$oSecondVersion = new version();
$oSecondVersion->iAppid = $oApp->iAppId;
$oSecondVersion->sName = __FUNCTION__." first version";
$oSecondVersion->iAppId = $oApp->iAppId; // $oApp is the parent
$oSecondVersion->create();
$oSuperMaintainer = new maintainer();
@@ -489,7 +547,9 @@ function test_maintainer_getMaintainersForAppIdVersionId()
if(!$hResult = maintainer::getMaintainersForAppIdVersionId($oApp->iAppId))
{
echo "Failed to get list of maintainers!\n";
error("Failed to get list of maintainers!");
$oUser->delete(); // delete the user
$oApp->delete(); // cleanup the application and its versions we created
return FALSE;
}
@@ -498,14 +558,18 @@ function test_maintainer_getMaintainersForAppIdVersionId()
$iReceived = mysql_num_rows($hResult);
if($iExpected != $iReceived)
{
echo "Got super maintainer count of $iReceived instead of $iExpected!\n";
error("Got super maintainer count of $iReceived instead of $iExpected!");
$oUser->delete(); // delete the user
$oApp->delete(); // cleanup the application and its versions we created
return FALSE;
}
if(!$hResult = maintainer::getMaintainersForAppIdVersionId(null,
$oFirstVersion->iVersionId))
{
echo "Failed to get list of maintainers!\n";
error("Failed to get list of maintainers!");
$oUser->delete(); // delete the user
$oApp->delete(); // cleanup the application and its versions we created
return FALSE;
}
@@ -514,11 +578,12 @@ function test_maintainer_getMaintainersForAppIdVersionId()
$iReceived = mysql_num_rows($hResult);
if($iExpected != $iReceived)
{
echo "Got maintainer count of $iReceived instead of $iExpected!\n";
error("Got maintainer count of $iReceived instead of $iExpected!");
$oUser->delete(); // delete the user
return FALSE;
}
$oSuperMaintainer->delete();
$oSuperMaintainer->delete(); // cleanup the super maintainer we created
/* Become a maintainer for one of the versions only */
$oFirstVersionMaintainer = new maintainer();
@@ -541,7 +606,9 @@ function test_maintainer_getMaintainersForAppIdVersionId()
if(!$hResult = maintainer::getMaintainersForAppIdVersionId(null,
$oFirstVersion->iVersionId))
{
echo "Failed to get list of maintainers!\n";
error("Failed to get list of maintainers!");
$oUser->delete(); // delete the user
$oApp->delete(); // cleanup the application and its versions we created
return FALSE;
}
@@ -550,14 +617,18 @@ function test_maintainer_getMaintainersForAppIdVersionId()
$iReceived = mysql_num_rows($hResult);
if($iExpected != $iReceived)
{
echo "Got maintainer count of $iReceived instead of $iExpected!\n";
error("Got maintainer count of $iReceived instead of $iExpected!");
$oUser->delete(); // delete the user
$oApp->delete(); // cleanup the application and its versions we created
return FALSE;
}
if(!$hResult = maintainer::getMaintainersForAppIdVersionId(null,
$oSecondVersion->iVersionId))
{
echo "Failed to get list of maintainers!\n";
error("Failed to get list of maintainers!");
$oUser->delete(); // delete the user
$oApp->delete(); // cleanup the application and its versions we created
return FALSE;
}
@@ -566,12 +637,16 @@ function test_maintainer_getMaintainersForAppIdVersionId()
$iReceived = mysql_num_rows($hResult);
if($iExpected != $iReceived)
{
echo "Got maintainer count of $iReceived instead of $iExpected!\n";
error("Got maintainer count of $iReceived instead of $iExpected!");
$oUser->delete(); // clean up the user
$oApp->delete(); // cleanup the application and its versions we created
return FALSE;
}
$oApp->delete();
$oUser->delete();
if(!$oApp->delete())
echo __FUNCTION__." oApp->delete() failed\n";
$oUser->delete(); // clean up the user
return TRUE;
}

View File

@@ -55,7 +55,7 @@ class notifyContainer
$_SESSION['current'] = $this->oUser;
// create a fake version
$this->iVersionId = create_version_and_parent_app();
$this->iVersionId = create_version_and_parent_app("test_maintainer_notify");
// create a queued entry for the user we just created
$this->oTestData = new testData();
@@ -595,7 +595,7 @@ function _test_maintainer_notifyMaintainersOfQueuedData($bTestAsMaintainer)
{
$bSuccess = true; // default to success
echo __FUNCTION__."\n";
test_start(__FUNCTION__);
$sFunction = "test_maintainer_notifyLevel_0_to_1";
if(!$sFunction($bTestAsMaintainer))
@@ -678,7 +678,9 @@ function test_maintainer_notifyMaintainersOfQueuedData()
{
$bSuccess = true;
echo "Testing as maintainer\n";
test_start(__FUNCTION__);
echo "\nTesting as maintainer\n";
if(!_test_maintainer_notifyMaintainersOfQueuedData(true))
{
echo "Maintainer test failed!\n";

View File

@@ -32,11 +32,16 @@ function test_class($sClassName, $aTestMethods)
return true;
/* Set up test user */
global $test_email, $test_password;
if(!$oUser = create_and_login_user())
$sTestEmail = __FUNCTION__."@localhost.com";
$sTestPassword = "password";
if(!$oUser = create_and_login_user($sTestEmail, $sTestPassword))
{
echo "Failed to create and log in user.\n";
error("Failed to create and log in user.");
return FALSE;
} else
{
// assign the session variable that makes this user the current user
$_SESSION['current'] = $oUser;
}
/* Test the class constructor */
@@ -48,16 +53,16 @@ function test_class($sClassName, $aTestMethods)
if(!$hResult)
{
echo "Got '$hResult' instead of a valid MySQL handle\n";
echo "FAILED\t\t$sClassName::$sClassName\n";
error("Got '$hResult' instead of a valid MySQL handle");
error("FAILED\t\t$sClassName::$sClassName");
$oTestObject->delete();
return FALSE;
}
if(!($oRow = mysql_fetch_object($hResult)))
{
echo "Failed to fetch MySQL object\n";
echo "FAILED\t\t$sClassName::$sClassName\n";
error("Failed to fetch MySQL object");
error("FAILED\t\t$sClassName::$sClassName");
$oTestObject->delete();
return FALSE;
}
@@ -102,16 +107,29 @@ function test_class($sClassName, $aTestMethods)
if(!$iReceived || !is_numeric($iReceived))
{
echo "Got '$iReceived' instead of a valid id\n";
echo "FAILED\t\t$sClassName::$sClassName()\n";
error("Got '$iReceived' instead of a valid id");
error("FAILED\t\t$sClassName::$sClassName()");
$oTestObject->delete();
return FALSE;
}
echo "PASSED\t\t$sClassName::$sClassName\n";
//////////////////////////
// cleanup after the test
cleanup($oTestObject);
$oTestObject->delete();
if(!$oUser->addPriv("admin"))
error("oUser->addPriv('admin') failed");
if(!$oTestObject->delete())
{
error("sClassName of $sClassName oTestObject->delete() failed!");
$oUser->delete();
return false;
}
////////////////////////////////
/* Test the methods' functionality */
foreach($aTestMethods as $sMethod)
@@ -130,8 +148,8 @@ function test_class($sClassName, $aTestMethods)
$iReceived = mysql_num_rows($hResult);
if($iExpected > $iReceived)
{
echo "Got $iReceived instead of >= $iExpected\n";
echo "FAILED\t\t$sClassName::$sMethod\n";
error("Got $iReceived instead of >= $iExpected");
error("FAILED\t\t$sClassName::$sMethod");
$oTestObject->delete();
return FALSE;
}
@@ -224,7 +242,7 @@ function create_object($sClassName, $oUser)
{
if(!$oTestObject->create())
{
echo "FAILED\t\t$sClassName::create()\n";
error("FAILED\t\t$sClassName::create()");
return FALSE;
}
} else
@@ -236,7 +254,7 @@ function create_object($sClassName, $oUser)
$oUser->iUserId);
if(!$hResult)
{
echo "FAILED\t\t$sClassName to create screenshot entry";
error("FAILED\t\t$sClassName to create screenshot entry");
return FALSE;
}
$oTestObject->iScreenshotId = mysql_insert_id();

View File

@@ -6,8 +6,9 @@ require_once(BASE."include/version.php");
function test_testData_getNewestTestidFromVersionId()
{
test_start(__FUNCTION__);
global $test_email, $test_password;
if(!$oUser = create_and_login_user())
$sTestEmail = __FUNCTION__."@localhost.com";
$sTestPassword = "password";
if(!$oUser = create_and_login_user($sTestEmail, $sTestPassword))
{
echo "Failed to create and log in user\n";
return FALSE;
@@ -30,14 +31,16 @@ function test_testData_getNewestTestidFromVersionId()
$iReceived = testData::getNewestTestidFromVersionId($iVersionId);
if($iExpected != $iReceived)
{
echo "Got testData id of $iReceived instead of $iExpected!\n";
error("Got testData id of $iReceived instead of $iExpected!");
$oOldTestData->delete();
$oNewTestData->delete();
$oUser->delete();
return FALSE;
}
$oOldTestData->delete();
$oNewTestData->delete();
$oUser->delete();
return TRUE;
}

View File

@@ -9,14 +9,14 @@ function test_url_update()
{
test_start(__FUNCTION__);
global $test_email, $test_password;
$bSuccess = true; // default to success until we detect failure
/* Log in */
if(!$oUser = create_and_login_user())
$sTestUser = __FUNCTION__."@localhost.com";
$sTestPassword = "password";
if(!$oUser = create_and_login_user($sTestUser, $sTestPassword))
{
echo "Received '$retval' instead of SUCCESS('".SUCCESS."').";
error("Received '$retval' instead of SUCCESS('".SUCCESS."').");
return FALSE;
}
@@ -37,25 +37,25 @@ function test_url_update()
if($oUrl->sDescription != $sDescriptionNew)
{
echo "Description is '$oUrl->sDescription' instead of '$sDescriptionNew'\n";
error("Description is '$oUrl->sDescription' instead of '$sDescriptionNew'");
$bSuccess = false;
}
if($oUrl->sUrl != $sUrlNew)
{
echo "Url is '$oUrl->sUrl' instead of '$sUrlNew'\n";
error("Url is '$oUrl->sUrl' instead of '$sUrlNew'");
$bSuccess = false;
}
if($oUrl->iVersionId != $iVersionIdNew)
{
echo "VersionId is '$oUrl->iVersionId' instead of '$iVersionIdNew'\n";
error("VersionId is '$oUrl->iVersionId' instead of '$iVersionIdNew'");
$bSuccess = false;
}
if($oUrl->iAppId != $iAppIdNew)
{
echo "AppId is '$oUrl->iAppId' instead of '$iAppIdNew'\n";
error("AppId is '$oUrl->iAppId' instead of '$iAppIdNew'");
$bSuccess = false;
}

View File

@@ -21,29 +21,8 @@ function test_user_create()
global $test_email, $test_password;
$oUser = new User();
/* delete the user if they already exist */
if($oUser->login($test_email, $test_password) == SUCCESS)
if(!($oUser = create_and_login_user($test_email, $test_password)))
{
$oUser->delete();
$oUser = new User();
} else
{
echo "User doesn't already exist\n";
}
/* create the user */
$retval = $oUser->create($test_email, $test_password, "Test user", "20051020");
if($retval != SUCCESS)
{
if($retval == USER_CREATE_EXISTS)
echo "The user already exists!\n";
else if($retval == USER_LOGIN_FAILED)
echo "User login failed!\n";
else
echo "ERROR: UNKNOWN ERROR!!\n";
return false;
}