Application::countWithRating() and getWithRating() should avoid queued applications. Add unit test
to ensure that we don't include queued applications
This commit is contained in:
@@ -371,7 +371,8 @@ class Application {
|
|||||||
{
|
{
|
||||||
$sQuery = "SELECT DISTINCT count(appId) as total
|
$sQuery = "SELECT DISTINCT count(appId) as total
|
||||||
FROM appVersion
|
FROM appVersion
|
||||||
WHERE maintainer_rating = '?'";
|
WHERE maintainer_rating = '?'
|
||||||
|
AND queued='false'";
|
||||||
|
|
||||||
if($hResult = query_parameters($sQuery, $sRating))
|
if($hResult = query_parameters($sQuery, $sRating))
|
||||||
{
|
{
|
||||||
@@ -386,6 +387,7 @@ class Application {
|
|||||||
$sQuery = "SELECT DISTINCT appId
|
$sQuery = "SELECT DISTINCT appId
|
||||||
FROM appVersion
|
FROM appVersion
|
||||||
WHERE maintainer_rating = '?'
|
WHERE maintainer_rating = '?'
|
||||||
|
AND queued = 'false'
|
||||||
ORDER BY appId ASC LIMIT ?, ?";
|
ORDER BY appId ASC LIMIT ?, ?";
|
||||||
|
|
||||||
if($hResult = query_parameters($sQuery, $sRating, $iOffset, $iItemsPerPage))
|
if($hResult = query_parameters($sQuery, $sRating, $iOffset, $iItemsPerPage))
|
||||||
|
|||||||
@@ -153,6 +153,50 @@ function test_application_getWithRating()
|
|||||||
|
|
||||||
delete_app_and_user($oApp, $oUser);
|
delete_app_and_user($oApp, $oUser);
|
||||||
|
|
||||||
|
|
||||||
|
//test to ensure getWithRating doesn't return applications that are queued
|
||||||
|
|
||||||
|
if(!$oUser = create_and_login_user()) //create user without admin priveliges
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
$oApp = new Application();
|
||||||
|
$oApp->sName = "Some application";
|
||||||
|
$oApp->sDescription = "some description";
|
||||||
|
$oApp->submitterId = $oUser->iUserId;
|
||||||
|
if(!$oApp->create())
|
||||||
|
{
|
||||||
|
$oUser->delete(); /* clean up the user we created prior to exiting */
|
||||||
|
echo "Failed to create application!\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$iAppId = $oApp->iAppId; /* use the iAppId of the application we just created */
|
||||||
|
|
||||||
|
$oVersion = new Version();
|
||||||
|
$oVersion->versionName = "Some Version".$iVersionIdIndex;
|
||||||
|
$oVersion->description = "Some Version description".$iVersionIdIndex;
|
||||||
|
$oVersion->iAppId = $oApp->iAppId;
|
||||||
|
$oVersion->sTestedRating = "Bronze";
|
||||||
|
$oVersion->sQueued = "True";
|
||||||
|
|
||||||
|
if(!$oVersion->create())
|
||||||
|
{
|
||||||
|
delete_app_and_user($oApp, $oUser);
|
||||||
|
echo "Failed to create version!\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$aApps=Application::getWithRating($sRating, $iOffset, $iItemsPerPage);
|
||||||
|
|
||||||
|
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";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,7 +241,7 @@ function create_and_login_user()
|
|||||||
echo "Got '".$retval."' instead of SUCCESS(".SUCCESS.")\n";
|
echo "Got '".$retval."' instead of SUCCESS(".SUCCESS.")\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $oUser;
|
return $oUser;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user