Unit tests should run with E_ALL so we can detect all errors. Fix dozens of errors that popped up after enabling all errors.
This commit is contained in:
@@ -49,6 +49,8 @@ class Application {
|
||||
if($hResult = query_parameters($sQuery, $iAppId))
|
||||
{
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
if($oRow)
|
||||
{
|
||||
$this->iAppId = $iAppId;
|
||||
$this->iVendorId = $oRow->vendorId;
|
||||
$this->iCatId = $oRow->catId;
|
||||
@@ -61,6 +63,7 @@ class Application {
|
||||
$this->sWebpage = $oRow->webPage;
|
||||
$this->sQueued = $oRow->queued;
|
||||
}
|
||||
}
|
||||
|
||||
/* fetch versions of this application, if there are any */
|
||||
$this->aVersionsIds = array();
|
||||
@@ -404,7 +407,10 @@ class Application {
|
||||
{
|
||||
$aClean = array(); //array of filtered user input
|
||||
|
||||
if(isset($_REQUEST['sReplyText']))
|
||||
$aClean['sReplyText'] = makeSafe($_REQUEST['sReplyText']);
|
||||
else
|
||||
$aClean['sReplyText'] = "";
|
||||
|
||||
switch($sAction)
|
||||
{
|
||||
|
||||
@@ -32,11 +32,13 @@ class Category {
|
||||
if($hResult = query_parameters($sQuery, $iCatId))
|
||||
{
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
if($oRow)
|
||||
{
|
||||
$this->iCatId = $iCatId;
|
||||
$this->iParentId = $oRow->catParent;
|
||||
$this->sName = $oRow->catName;
|
||||
$this->sDescription = $oRow->catDescription;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -32,6 +32,8 @@ class distribution{
|
||||
if($hResult = query_parameters($sQuery, $iDistributionId))
|
||||
{
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
if($oRow)
|
||||
{
|
||||
$this->iDistributionId = $iDistributionId;
|
||||
$this->sName = $oRow->name;
|
||||
$this->sDescription = $oRow->description;
|
||||
@@ -41,6 +43,7 @@ class distribution{
|
||||
$this->sQueued = $oRow->queued;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We fetch Test Result Ids.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
define(ERROR_SQL, "sql_error");
|
||||
define(ERROR_GENERAL, "general_error");
|
||||
define("ERROR_SQL", "sql_error");
|
||||
define("ERROR_GENERAL", "general_error");
|
||||
|
||||
class error_log
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ class Image {
|
||||
$this->iHeight = $oInfo[1];
|
||||
$this->iType = $oInfo[2];
|
||||
|
||||
$this->set_debuglog("New image class created with as $sFile as"
|
||||
$this->set_debuglog("New image class created with as $this->sFile as"
|
||||
." file and {$oInfo[2]} as type. Dimensions"
|
||||
." {$oInfo[0]}x{$oInfo[1]}");
|
||||
}
|
||||
@@ -214,7 +214,7 @@ class Image {
|
||||
$iNewWidth,$iNewHeight,$this->iWidth,$this->iHeight);
|
||||
}
|
||||
|
||||
$this->set_debuglog("imagecopyresized($new,$this->oImage,0,0,0,0,$iNewWidth,"
|
||||
$this->set_debuglog("imagecopyresized($oNewImage,$this->oImage,0,0,0,0,$iNewWidth,"
|
||||
."$iNewHeight,$this->iWidth,$this->iHeight);");
|
||||
imagedestroy($this->oImage);
|
||||
$this->oImage = $oNewImage;
|
||||
@@ -231,7 +231,6 @@ class Image {
|
||||
*/
|
||||
function resize_image_border($sBorderColor, $iBorderWidth, $iNewHeight, $iNewWidth)
|
||||
{
|
||||
|
||||
$r = hexdec(substr($sBorderColor, 1, 2));
|
||||
$g = hexdec(substr($sBorderColor, 3, 2));
|
||||
$b = hexdec(substr($sBorderColor, 5, 2));
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
// get modules
|
||||
ini_set("memory_limit","64M");
|
||||
require(BASE."include/config.php");
|
||||
require_once(BASE."include/config.php");
|
||||
require(BASE."include/util.php");
|
||||
require(BASE."include/user.php");
|
||||
require(BASE."include/session.php");
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
require_once(BASE."include/config.php");
|
||||
|
||||
function mail_appdb($sEmailList,$sSubject,$sMsg)
|
||||
{
|
||||
$sHeaders = "MIME-Version: 1.0\r\n";
|
||||
|
||||
@@ -24,6 +24,8 @@ class maintainer
|
||||
if($hResult)
|
||||
{
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
if($oRow)
|
||||
{
|
||||
$this->iMaintainerId = $oRow->maintainerId;
|
||||
$this->iAppId = $oRow->appId;
|
||||
$this->iVersionId = $oRow->versionId;
|
||||
@@ -34,6 +36,7 @@ class maintainer
|
||||
$this->bQueued = $oRow->queued;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function create()
|
||||
{
|
||||
@@ -73,8 +76,8 @@ class maintainer
|
||||
{
|
||||
$sStatusMessage = "<p>The maintainer was successfully added into the database</p>\n";
|
||||
|
||||
$oApp = new Application($iAppId);
|
||||
$oVersion = new Version($iVersionId);
|
||||
$oApp = new Application($this->iAppId);
|
||||
$oVersion = new Version($this->iVersionId);
|
||||
//Send Status Email
|
||||
$sEmail = $oUser->sEmail;
|
||||
if ($sEmail)
|
||||
|
||||
@@ -26,11 +26,13 @@ class Monitor {
|
||||
WHERE monitorId = '".$iMonitorId."'";
|
||||
$hResult = query_appdb($sQuery);
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
if($oRow)
|
||||
{
|
||||
$this->iMonitorId = $oRow->monitorId;
|
||||
$this->iAppId = $oRow->appId;
|
||||
$this->iVersionId = $oRow->versionId;
|
||||
$this->iUserId = $oRow->userId;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,10 @@ require_once(BASE."include/util.php");
|
||||
require_once(BASE."include/version.php");
|
||||
|
||||
$aClean = array(); //array of filtered user input
|
||||
if(isset($_REQUEST['sReplyText']))
|
||||
$aClean['sReplyText'] = makeSafe( $_REQUEST['sReplyText'] );
|
||||
else
|
||||
$aClean['sReplyText'] = "";
|
||||
|
||||
/************************************/
|
||||
/* note class and related functions */
|
||||
@@ -34,6 +37,8 @@ class Note {
|
||||
AND noteId = '?'";
|
||||
$hResult = query_parameters($sQuery, $iNoteId);
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
if($oRow)
|
||||
{
|
||||
$this->iNoteId = $oRow->noteId;
|
||||
$this->iAppId = $oRow->appId;
|
||||
$this->iVersionId = $oRow->versionId;
|
||||
@@ -41,6 +46,7 @@ class Note {
|
||||
$this->sDescription = $oRow->noteDesc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
$hAppdbLink = null;
|
||||
$hBugzillaLink = null;
|
||||
|
||||
define(MYSQL_DEADLOCK_ERRNO, 1213);
|
||||
define("MYSQL_DEADLOCK_ERRNO", 1213);
|
||||
|
||||
function query_appdb($sQuery,$sComment="")
|
||||
{
|
||||
|
||||
@@ -40,6 +40,8 @@ class Screenshot {
|
||||
if($hResult)
|
||||
{
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
if($oRow)
|
||||
{
|
||||
$this->iScreenshotId = $iScreenshotId;
|
||||
$this->sDescription = $oRow->description;
|
||||
$this->iAppId = $oRow->appId;
|
||||
@@ -51,6 +53,7 @@ class Screenshot {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
/* the number of days a session cookie is flaged to last */
|
||||
define(SESSION_DAYS_TO_EXPIRE, 2);
|
||||
define("SESSION_DAYS_TO_EXPIRE", 2);
|
||||
|
||||
class session
|
||||
{
|
||||
@@ -73,7 +73,10 @@ class session
|
||||
$result = query_parameters("SELECT data FROM session_list WHERE session_id = '?'", $key);
|
||||
if (!$result) { return null; }
|
||||
$oRow = mysql_fetch_object($result);
|
||||
if($oRow)
|
||||
return $oRow->data;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// write session to DB
|
||||
|
||||
@@ -38,6 +38,8 @@ class testData{
|
||||
if($hResult = query_parameters($sQuery, $iTestingId))
|
||||
{
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
if($oRow)
|
||||
{
|
||||
$this->iTestingId = $oRow->testingId;
|
||||
$this->iVersionId = $oRow->versionId;
|
||||
$this->sWhatWorks = $oRow->whatWorks;
|
||||
@@ -57,6 +59,7 @@ class testData{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a new Test Results.
|
||||
function create()
|
||||
|
||||
@@ -7,13 +7,13 @@ require_once(BASE."include/version.php");
|
||||
require_once(BASE."include/maintainer.php");
|
||||
require_once(BASE."include/util.php");
|
||||
|
||||
define(SUCCESS, 0);
|
||||
define(USER_CREATE_EXISTS, 1);
|
||||
define(USER_CREATE_FAILED, 2);
|
||||
define(USER_LOGIN_FAILED, 3);
|
||||
define(USER_UPDATE_FAILED, 4);
|
||||
define(USER_UPDATE_FAILED_EMAIL_EXISTS, 5); /* user updating to an email address that is already in use */
|
||||
define(USER_UPDATE_FAILED_NOT_LOGGED_IN, 6); /* user::update() called but user not logged in */
|
||||
define("SUCCESS", 0);
|
||||
define("USER_CREATE_EXISTS", 1);
|
||||
define("USER_CREATE_FAILED", 2);
|
||||
define("USER_LOGIN_FAILED", 3);
|
||||
define("USER_UPDATE_FAILED", 4);
|
||||
define("USER_UPDATE_FAILED_EMAIL_EXISTS", 5); /* user updating to an email address that is already in use */
|
||||
define("USER_UPDATE_FAILED_NOT_LOGGED_IN", 6); /* user::update() called but user not logged in */
|
||||
|
||||
/**
|
||||
* User class for handling users
|
||||
@@ -41,6 +41,8 @@ class User {
|
||||
WHERE userId = '?'";
|
||||
$hResult = query_parameters($sQuery, $iUserId);
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
if($oRow)
|
||||
{
|
||||
$this->iUserId = $oRow->userid;
|
||||
$this->sEmail = $oRow->email;
|
||||
$this->sRealname = $oRow->realname;
|
||||
@@ -49,6 +51,7 @@ class User {
|
||||
$this->sWineRelease = $oRow->CVSrelease;
|
||||
$this->bInactivityWarned = $oRow->inactivity_warned;
|
||||
}
|
||||
}
|
||||
return $this->isLoggedIn();
|
||||
}
|
||||
|
||||
@@ -65,12 +68,16 @@ class User {
|
||||
$hResult = query_parameters($sQuery, $sEmail, $sPassword);
|
||||
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
if($oRow)
|
||||
{
|
||||
$this->iUserId = $oRow->userid;
|
||||
$this->sEmail = $oRow->email;
|
||||
$this->sRealname = $oRow->realname;
|
||||
$this->sStamp = $oRow->stamp;
|
||||
$this->sDateCreated = $oRow->created;
|
||||
$this->sWineRelease = $oRow->CVSrelease;
|
||||
}
|
||||
|
||||
if($this->isLoggedIn())
|
||||
{
|
||||
// Update timestamp and clear the inactivity flag if it was set
|
||||
@@ -740,13 +747,19 @@ class User {
|
||||
while($oRow = mysql_fetch_object($hResult))
|
||||
{
|
||||
$i = array_search($oRow->userid, $aUserId);
|
||||
if ($aUserId[$i] != array($oRow->userid))
|
||||
|
||||
// if we didn't find this entry in the $aUserId
|
||||
// array then we should add it
|
||||
if($i === false)
|
||||
{
|
||||
$aUserId[$c] = array($oRow->userid);
|
||||
$c++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// go through the email entries and only add the emails for the users
|
||||
// that want to receive it
|
||||
if ($c > 0)
|
||||
{
|
||||
while(list($index, list($userIdValue)) = each($aUserId))
|
||||
@@ -756,6 +769,7 @@ class User {
|
||||
$retval .= $oUser->sEmail." ";
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,23 +45,23 @@ class Version {
|
||||
if($hResult = query_parameters($sQuery, $iVersionId))
|
||||
{
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
if($oRow)
|
||||
{
|
||||
$this->iVersionId = $iVersionId;
|
||||
$this->iAppId = $oRow->appId;
|
||||
$this->iCatId = $oRow->catId;
|
||||
$this->iSubmitterId = $oRow->submitterId;
|
||||
$this->sSubmitTime = $oRow->submitTime;
|
||||
$this->sDate = $oRow->submitTime;
|
||||
$this->sName = $oRow->versionName;
|
||||
$this->sKeywords = $oRow->keywords;
|
||||
$this->sDescription = $oRow->description;
|
||||
$this->sTestedRelease = $oRow->maintainer_release;
|
||||
$this->sTestedRating = $oRow->maintainer_rating;
|
||||
$this->sWebpage = $oRow->webPage;
|
||||
$this->sQueued = $oRow->queued;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -394,7 +394,12 @@ class Version {
|
||||
function mailSubmitter($sAction="add")
|
||||
{
|
||||
$aClean = array(); //array of filtered user input
|
||||
|
||||
// use 'sReplyText' if it is defined, otherwise define the value as an empty string
|
||||
if(isset($_REQUEST['sReplyText']))
|
||||
$aClean['sReplyText'] = makeSafe($_REQUEST['sReplyText']);
|
||||
else
|
||||
$aClean['sReplyText'] = "";
|
||||
|
||||
if($this->iSubmitterId)
|
||||
{
|
||||
@@ -432,7 +437,12 @@ class Version {
|
||||
function SendNotificationMail($sAction="add",$sMsg=null)
|
||||
{
|
||||
$aClean = array(); //array of filtered user input
|
||||
|
||||
// use 'sReplyText' if it is defined, otherwise define the value as an empty string
|
||||
if(isset($_REQUEST['sReplyText']))
|
||||
$aClean['sReplyText'] = makeSafe($_REQUEST['sReplyText']);
|
||||
else
|
||||
$aClean['sReplyText'] = "";
|
||||
|
||||
$oApp = new Application($this->iAppId);
|
||||
switch($sAction)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/* TODO: test the rest of the classes we have */
|
||||
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include_once("test_user.php");
|
||||
echo "\n";
|
||||
|
||||
@@ -249,13 +249,13 @@ function create_and_login_user()
|
||||
if(!test_application_delete())
|
||||
echo "test_application_delete() failed!\n";
|
||||
else
|
||||
echo "test_application_delete() passed!\n";
|
||||
echo "test_application_delete() passed\n";
|
||||
|
||||
|
||||
if(!test_application_getWithRating())
|
||||
echo "test_application_getWithRating() failed!\n";
|
||||
else
|
||||
echo "test_application_getWithRating() passed!\n";
|
||||
echo "test_application_getWithRating() passed\n";
|
||||
|
||||
?>
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
require_once("path.php");
|
||||
require_once("test_common.php");
|
||||
|
||||
DEFINE(TEST_IMAGE_FILENAME, "/images/appdb_montage.jpg");
|
||||
DEFINE(TEST_IMAGE_OUTPUT_FILENAME, "/tmp/tmpfile.png");
|
||||
DEFINE(TEST_IMAGE_WIDTH, 391);
|
||||
DEFINE(TEST_IMAGE_HEIGHT, 266);
|
||||
DEFINE(TEST_IMAGE_WATERMARK, "/images/watermark.png");
|
||||
DEFINE("TEST_IMAGE_FILENAME", "/images/appdb_montage.jpg");
|
||||
DEFINE("TEST_IMAGE_OUTPUT_FILENAME", "/tmp/tmpfile.png");
|
||||
DEFINE("TEST_IMAGE_WIDTH", 391);
|
||||
DEFINE("TEST_IMAGE_HEIGHT", 266);
|
||||
DEFINE("TEST_IMAGE_WATERMARK", "/images/watermark.png");
|
||||
|
||||
function test_image_constructor()
|
||||
{
|
||||
@@ -73,7 +73,7 @@ function test_image_make_thumbnail()
|
||||
from the ratio of the height
|
||||
to width of the original image */
|
||||
$iBorderWidth = 20;
|
||||
$oImage->make_thumb($iWidth, $iHeight, $iBorderWidthm, "#0000FF");
|
||||
$oImage->make_thumb($iWidth, $iHeight, $iBorderWidth, "#0000FF");
|
||||
|
||||
/* did we get the correct size? */
|
||||
$iActualWidth = $oImage->get_width();
|
||||
|
||||
@@ -121,7 +121,7 @@ function test_query_parameters()
|
||||
if(!test_query_parameters())
|
||||
echo "test_query_parameters() failed!\n";
|
||||
else
|
||||
echo "test_query_parameters() passed!\n";
|
||||
echo "test_query_parameters() passed\n";
|
||||
|
||||
|
||||
?>
|
||||
@@ -28,10 +28,13 @@ function test_user_create()
|
||||
{
|
||||
$oUser->delete();
|
||||
$oUser = new User();
|
||||
} else
|
||||
{
|
||||
echo "User doesn't already exist\n";
|
||||
}
|
||||
|
||||
/* create the user */
|
||||
$retval = $oUser->create("testemail@somesite.com", "password", "Test user", "20051020");
|
||||
$retval = $oUser->create($test_email, $test_password, "Test user", "20051020");
|
||||
if($retval != SUCCESS)
|
||||
{
|
||||
if($retval == USER_CREATE_EXISTS)
|
||||
@@ -45,7 +48,7 @@ function test_user_create()
|
||||
}
|
||||
|
||||
/* try creating the user again, see that we get USER_CREATE_EXISTS */
|
||||
$retval = $oUser->create("testemail@somesite.com", "password", "Test user", "20051020");
|
||||
$retval = $oUser->create($test_email, $test_password, "Test user", "20051020");
|
||||
if($retval != USER_CREATE_EXISTS)
|
||||
{
|
||||
echo "Got '".$retval."' instead of USER_CREATE_EXISTS(".USER_CREATE_EXISTS.")\n";
|
||||
@@ -68,15 +71,17 @@ function test_user_login()
|
||||
$retval = $oUser->login($test_email, $test_password);
|
||||
if($retval != SUCCESS)
|
||||
{
|
||||
echo "Test that correct information results in a correct login FAILED\n";
|
||||
echo "Got '".$retval."' instead of SUCCESS(".SUCCESS.")\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* test that incorrect user results in a login failed */
|
||||
$oUser = new User();
|
||||
$retval = $oUser->login("some nutty username", $testpassword);
|
||||
$retval = $oUser->login("some nutty username", $test_password);
|
||||
if($retval != USER_LOGIN_FAILED)
|
||||
{
|
||||
echo "Test that incorrect user results in a failed login FAILED\n";
|
||||
echo "Got '".$retval."' instead of SUCCESS(".SUCCESS.")\n";
|
||||
return false;
|
||||
}
|
||||
@@ -86,6 +91,7 @@ function test_user_login()
|
||||
$retval = $oUser->login($test_email, "some password");
|
||||
if($retval != USER_LOGIN_FAILED)
|
||||
{
|
||||
echo "Test that incorrect passowrd results in a login failed FAILED\n";
|
||||
echo "Got '".$retval."' instead of SUCCESS(".SUCCESS.")\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user