test_om_objects: Extend objectGetEntries test
This commit is contained in:
committed by
Chris Morgan
parent
55d9f32c0a
commit
d8c67b4740
@@ -437,6 +437,11 @@ class downloadurl
|
|||||||
return appData::objectGetEntries($sState, $iRows, $iStart, 'downloadurl');
|
return appData::objectGetEntries($sState, $iRows, $iStart, 'downloadurl');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function objectGetEntriesCount($sState)
|
||||||
|
{
|
||||||
|
return appData::objectGetEntriesCount($sState, 'downloadurl');
|
||||||
|
}
|
||||||
|
|
||||||
function objectGetHeader()
|
function objectGetHeader()
|
||||||
{
|
{
|
||||||
return appData::objectGetHeader("downloadurl");
|
return appData::objectGetHeader("downloadurl");
|
||||||
|
|||||||
@@ -327,6 +327,20 @@ class Note {
|
|||||||
return $hResult;
|
return $hResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function objectGetEntriesCount($sState)
|
||||||
|
{
|
||||||
|
$sQuery = "SELECT COUNT(DISTINCT noteId) as count FROM appNotes";
|
||||||
|
$hResult = query_parameters($sQuery);
|
||||||
|
|
||||||
|
if(!$hResult)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(($oRow = mysql_fetch_object($hResult)))
|
||||||
|
return $oRow->count;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: not sure how to best let users view a table of notes
|
//TODO: not sure how to best let users view a table of notes
|
||||||
// since the note contents could be very long we would only
|
// since the note contents could be very long we would only
|
||||||
// want to show a small amount of the text. Implement this
|
// want to show a small amount of the text. Implement this
|
||||||
|
|||||||
@@ -97,9 +97,7 @@ function test_class($sClassName, $aTestMethods)
|
|||||||
{
|
{
|
||||||
switch($sMethod)
|
switch($sMethod)
|
||||||
{
|
{
|
||||||
/* Should also test for queued entries, but vendor does not support
|
case 'objectGetEntries':
|
||||||
queueing yet */
|
|
||||||
case "objectGetEntries":
|
|
||||||
if(!$oTestObject = create_object($sClassName, $oUser))
|
if(!$oTestObject = create_object($sClassName, $oUser))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@@ -115,8 +113,38 @@ function test_class($sClassName, $aTestMethods)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Create an object as a regular user */
|
||||||
|
$oTestObject2 = create_object($sClassName, $oUser, false);
|
||||||
|
|
||||||
|
/* objectGetEntries() and objectGetEntriesCount() should return matching results */
|
||||||
|
$iExpected = mysql_num_rows($oTestObject2->objectGetEntries('accepted'));
|
||||||
|
$iReceived = $oTestObject2->objectGetEntriesCount('accepted');
|
||||||
|
if($iExpected != $iReceived)
|
||||||
|
{
|
||||||
|
error("ObjectGetEntriesCount returned $iReceived, objectGetEntries fetched $iExpected rows\n");
|
||||||
|
error("FAILED\t\t$sClassName::$sMethod");
|
||||||
|
cleanup_and_purge($oTestObject, $oUser);
|
||||||
|
cleanup_and_purge($oTestObject2, $oUser);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now test for queued objects, as admin */
|
||||||
|
$oUser->addPriv('admin');
|
||||||
|
$iExpected = mysql_num_rows($oTestObject2->objectGetEntries('queued'));
|
||||||
|
$iReceived = $oTestObject2->objectGetEntriesCount('queued');
|
||||||
|
$oUser->delPriv('admin');
|
||||||
|
if($iExpected != $iReceived)
|
||||||
|
{
|
||||||
|
error("ObjectGetEntriesCount returned $iReceived, objectGetEntries fetched $iExpected rows\n");
|
||||||
|
error("FAILED\t\t$sClassName::$sMethod");
|
||||||
|
cleanup_and_purge($oTestObject, $oUser);
|
||||||
|
cleanup_and_purge($oTestObject2, $oUser);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Class specific clean-up */
|
/* Class specific clean-up */
|
||||||
cleanup_and_purge($oTestObject, $oUser);
|
cleanup_and_purge($oTestObject, $oUser);
|
||||||
|
cleanup_and_purge($oTestObject2, $oUser);
|
||||||
|
|
||||||
echo "PASSED\t\t$sClassName::$sMethod\n";
|
echo "PASSED\t\t$sClassName::$sMethod\n";
|
||||||
break;
|
break;
|
||||||
@@ -190,6 +218,14 @@ function cleanup_and_purge($oObject, $oUser)
|
|||||||
cleanup($oObject);
|
cleanup($oObject);
|
||||||
$oObject->purge();
|
$oObject->purge();
|
||||||
|
|
||||||
|
switch(get_class($oObject))
|
||||||
|
{
|
||||||
|
case 'application':
|
||||||
|
$oVendor = new vendor($oObject->iVendorId);
|
||||||
|
$oVendor->purge();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if(!$bWasAdmin)
|
if(!$bWasAdmin)
|
||||||
$oUser->delPriv('admin');
|
$oUser->delPriv('admin');
|
||||||
}
|
}
|
||||||
@@ -203,6 +239,13 @@ function create_object($sClassName, $oUser, $bAsAdmin = true)
|
|||||||
/* Set up one test entry, depending on class */
|
/* Set up one test entry, depending on class */
|
||||||
switch($sClassName)
|
switch($sClassName)
|
||||||
{
|
{
|
||||||
|
// Some application functions require a vendor to be set
|
||||||
|
case 'application':
|
||||||
|
$oVendor = new vendor();
|
||||||
|
$oVendor->create();
|
||||||
|
$oTestObject->iVendorId = $oVendor->objectGetId();
|
||||||
|
break;
|
||||||
|
|
||||||
case "bug":
|
case "bug":
|
||||||
// create a bug in the bugzilla database, we need a valid
|
// create a bug in the bugzilla database, we need a valid
|
||||||
// bug id to create a bug entry
|
// bug id to create a bug entry
|
||||||
@@ -304,6 +347,7 @@ function test_object_methods()
|
|||||||
"mustBeQueued",
|
"mustBeQueued",
|
||||||
"objectGetChildren",
|
"objectGetChildren",
|
||||||
"objectGetEntries",
|
"objectGetEntries",
|
||||||
|
'objectGetEntriesCount',
|
||||||
"objectGetHeader",
|
"objectGetHeader",
|
||||||
"objectGetId",
|
"objectGetId",
|
||||||
"objectGetMail",
|
"objectGetMail",
|
||||||
|
|||||||
Reference in New Issue
Block a user