appdb/ include/maintainer.php unit_test/test_m ...

WineHQ wineowner at wine.codeweavers.com
Tue Jan 23 22:10:05 CST 2007


ChangeSet ID:	30908
CVSROOT:	/opt/cvs-commit
Module name:	appdb
Changes by:	wineowner at winehq.org	2007/01/23 22:10:05

Modified files:
	include        : maintainer.php 
	unit_test      : test_maintainer.php 

Log message:
	Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
	Disallowid of 0 in deleteMaintainersForVersion(). Add a unit test to ensure that
	deleteMaintainersForVersion() behaves properly.

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

Old revision  New revision  Changes     Path
 1.24          1.25          +3 -0       appdb/include/maintainer.php
 1.4           1.5           +37 -0      appdb/unit_test/test_maintainer.php

Index: appdb/include/maintainer.php
diff -u -p appdb/include/maintainer.php:1.24 appdb/include/maintainer.php:1.25
--- appdb/include/maintainer.php:1.24	24 Jan 2007  4:10: 5 -0000
+++ appdb/include/maintainer.php	24 Jan 2007  4:10: 5 -0000
@@ -178,6 +178,9 @@ class maintainer
 
     function deleteMaintainersForVersion($oVersion)
     {
+        if(!$oVersion->iVersionId)
+            return FALSE;
+
         $hResult = query_parameters("DELETE from appMaintainers WHERE versionId='?'",
                                     $oVersion->iVersionId);
     }
Index: appdb/unit_test/test_maintainer.php
diff -u -p appdb/unit_test/test_maintainer.php:1.4 appdb/unit_test/test_maintainer.php:1.5
--- appdb/unit_test/test_maintainer.php:1.4	24 Jan 2007  4:10: 5 -0000
+++ appdb/unit_test/test_maintainer.php	24 Jan 2007  4:10: 5 -0000
@@ -305,6 +305,38 @@ function test_superMaintainerOnAppSubmit
     return true;
 }
 
+/* deleteMaintainersForVersion() should fail if versionId = 0
+   Otherwise it will delete all super maintainers */
+function test_maintainer_deleteMaintainersForVersion()
+{
+    test_start(__FUNCTION__);
+
+    global $test_email, $test_password;
+
+    $oUser = new user();
+    $oUser->login($test_email, $test_password);
+
+    $oMaintainer = new maintainer();
+    $oMaintainer->iAppId = 655000;
+    $oMaintainer->iVersionId = 0;
+    $oMaintainer->iUserId = 655000;
+    $oMaintainer->sMaintainReason = "Silly reason";
+    $oMaintainer->bSuperMaintainer = 1;
+
+    $oMaintainer->create();
+
+    $oVersion = new version();
+    $oVersion->iVersionId = 0;
+
+    if(maintainer::deleteMaintainersForVersion($oVersion) !== FALSE)
+    {
+        echo "Got success, but this should fail.\n";
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
 if(!test_maintainer_getMaintainerCountForUser())
     echo "test_maintainer_getMaintainerCountForUser() failed!\n";
 else
@@ -327,4 +359,9 @@ if(!test_superMaintainerOnAppSubmit())
 else
     echo "test_superMaintainerOnAppSubmit() passed\n";
 
+if(!test_maintainer_deleteMaintainersForVersion())
+    echo "test_maintainer_deleteMaintainersForVersion() failed!\n";
+else
+    echo "test_maintainer_deleteMaintianersForVersion() passed\n";
+
 ?>



More information about the wine-cvs mailing list