appdb/unit_test test_maintainer.php

WineHQ wineowner at wine.codeweavers.com
Sun Apr 8 18:06:27 CDT 2007


ChangeSet ID:	31036
CVSROOT:	/opt/cvs-commit
Module name:	appdb
Changes by:	wineowner at winehq.org	2007/04/08 18:06:27

Modified files:
	unit_test      : test_maintainer.php 

Log message:
	Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
	test maintainer::getMaintainersForAppIdVersionId()

Patch: http://cvs.winehq.org/patch.py?id=31036

Old revision  New revision  Changes     Path
 1.8           1.9           +118 -0     appdb/unit_test/test_maintainer.php

Index: appdb/unit_test/test_maintainer.php
diff -u -p appdb/unit_test/test_maintainer.php:1.8 appdb/unit_test/test_maintainer.php:1.9
--- appdb/unit_test/test_maintainer.php:1.8	8 Apr 2007 23: 6:27 -0000
+++ appdb/unit_test/test_maintainer.php	8 Apr 2007 23: 6:27 -0000
@@ -447,6 +447,115 @@ function test_maintainer_deleteMaintaine
     return TRUE;
 }
 
+function test_maintainer_getMaintainersForAppIdVersionId()
+{
+    test_start(__FUNCTION__);
+
+    global $test_email, $test_password;
+    $oUser = new user();
+    if($oUser->login($test_email, $test_password) != SUCCESS)
+    {
+        echo "Failed to create and log in user!\n";
+        return FALSE;
+    }
+
+    $oUser->addPriv("admin");
+
+    $oApp = new application();
+    $oApp->create();
+    $oFirstVersion = new version();
+    $oFirstVersion->iAppId = $oApp->iAppId;
+    $oFirstVersion->create();
+    $oSecondVersion = new version();
+    $oSecondVersion->iAppid = $oApp->iAppId;
+    $oSecondVersion->create();
+
+    $oSuperMaintainer = new maintainer();
+    $oSuperMaintainer->bSuperMaintainer = TRUE;
+    $oSuperMaintainer->sMaintainReason = "Because";
+    $oSuperMaintainer->iAppId = $oApp->iAppId;
+    $oSuperMaintainer->iUserId = $oUser->iUserId;
+    $oSuperMaintainer->create();
+
+    if(!$hResult = maintainer::getMaintainersForAppIdVersionId($oApp->iAppId))
+    {
+        echo "Failed to get list of maintainers!\n";
+        return FALSE;
+    }
+
+    /* The application should have one maintainer */
+    $iExpected = 1;
+    $iReceived = mysql_num_rows($hResult);
+    if($iExpected != $iReceived)
+    {
+        echo "Got super maintainer count of $iReceived instead of $iExpected!\n";
+        return FALSE;
+    }
+
+    if(!$hResult = maintainer::getMaintainersForAppIdVersionId(null,
+       $oFirstVersion->iVersionId))
+    {
+        echo "Failed to get list of maintainers!\n";
+        return FALSE;
+    }
+
+    /* The version should have one maintainer */
+    $iExpected = 1;
+    $iReceived = mysql_num_rows($hResult);
+    if($iExpected != $iReceived)
+    {
+        echo "Got maintainer count of $iReceived instead of $iExpected!\n";
+        return FALSE;
+    }
+
+    $oSuperMaintainer->delete();
+
+    /* Become a maintainer for one of the versions only */
+    $oFirstVersionMaintainer = new maintainer();
+    $oFirstVersionMaintainer->sMaintainReason = "I need it";
+    $oFirstVersionMaintainer->iVersionId = $oFirstVersion->iVersionId;
+    $oFirstVersionMaintainer->iAppId = $oFirstVersion->iAppId;
+    $oFisrtVersionMaintainer->bSuperMaintainer = FALSE;
+    $oFirstVersionMaintainer->iUserId = $oUser->iUserId;
+    $oFirstVersionMaintainer->create();
+
+    if(!$hResult = maintainer::getMaintainersForAppIdVersionId(null,
+       $oFirstVersion->iVersionId))
+    {
+        echo "Failed to get list of maintainers!\n";
+        return FALSE;
+    }
+
+    /* The first version should have one maintainer */
+    $iExpected = 1;
+    $iReceived = mysql_num_rows($hResult);
+    if($iExpected != $iReceived)
+    {
+        echo "Got maintainer count of $iReceived instead of $iExpected!\n";
+        return FALSE;
+    }
+
+    if(!$hResult = maintainer::getMaintainersForAppIdVersionId(null,
+           $oSecondVersion->iVersionId))
+    {
+        echo "Failed to get list of maintainers!\n";
+        return FALSE;
+    }
+
+    /* The second version should not have any maintainers */
+    $iExpected = 0;
+    $iReceived = mysql_num_rows($hResult);
+    if($iExpected != $iReceived)
+    {
+        echo "Got maintainer count of $iReceived instead of $iExpected!\n";
+        return FALSE;
+    }
+
+    $oApp->delete();
+    $oUser->delete();
+
+    return TRUE;
+}
 if(!test_maintainer_getMaintainerCountForUser())
 {
     echo "test_maintainer_getMaintainerCountForUser() failed!\n";
@@ -494,4 +603,13 @@ if(!test_maintainer_deleteMaintainersFor
     echo "test_maintainer_deleteMaintianersForVersion() passed\n";
 }
 
+if(!test_maintainer_getMaintainersForAppIdVersionId())
+{
+    echo "test_maintainer_getMaintainersForAppIdVersionId() failed!\n";
+    $bTestSuccess = false;
+} else
+{
+    echo "test_maintainer_getMaintainersForAppIdVersionId() passed\n";
+}
+
 ?>



More information about the wine-cvs mailing list