[Fusionforge-commits] r7705 - in trunk: gforge/www/admin/trove gforge/www/include tests/func/Site

Alain Peyrat aljeux at libremir.placard.fr.eu.org
Thu May 28 22:07:03 CEST 2009


Author: aljeux
Date: 2009-05-28 22:07:03 +0200 (Thu, 28 May 2009)
New Revision: 7705

Added:
   trunk/tests/func/Site/trove.php
Modified:
   trunk/gforge/www/admin/trove/trove_cat_edit.php
   trunk/gforge/www/include/trove.php
   trunk/tests/func/Site/AllTests.php
Log:
Applied patch [#38] [4.7.3] Delete trove categories recursively

Modified: trunk/gforge/www/admin/trove/trove_cat_edit.php
===================================================================
--- trunk/gforge/www/admin/trove/trove_cat_edit.php	2009-05-28 19:39:53 UTC (rev 7704)
+++ trunk/gforge/www/admin/trove/trove_cat_edit.php	2009-05-28 20:07:03 UTC (rev 7705)
@@ -87,26 +87,7 @@
 	if ($form_trove_cat_id==$default_trove_cat){
 		exit_error( _('Error In Trove Operation, can\'t delete trove category define as default in local.inc'));
 	}
-	$res=db_query("SELECT * FROM trove_cat WHERE parent='$form_trove_cat_id'");
-	if (!$res) {
-		exit_error( _('Error In Trove Operation'), db_error());
-	}
-	if (db_numrows($res)>0) {
-		exit_error( _('Can\'t delete, That trove cat has sub categories'), db_error());
-	} else {
-		$res=db_query("DELETE FROM trove_treesums WHERE trove_cat_id='$form_trove_cat_id'");
-		if (!$res) {
-			exit_error( _('Error In Trove Operation'), db_error());
-		}
-		$res=db_query("DELETE FROM trove_group_link WHERE trove_cat_id='$form_trove_cat_id'");
-		if (!$res) {
-			exit_error( _('Error In Trove Operation'), db_error());
-		}
-		$res=db_query("DELETE FROM trove_cat WHERE trove_cat_id='$form_trove_cat_id'");
-		if (!$res || db_affected_rows($res)<1) {
-			exit_error( _('Error In Trove Operation'), db_error());
-		}
-	}
+	trove_del_cat_id($form_trove_cat_id);
 	session_redirect("/admin/trove/trove_cat_list.php");
 }
 

Modified: trunk/gforge/www/include/trove.php
===================================================================
--- trunk/gforge/www/include/trove.php	2009-05-28 19:39:53 UTC (rev 7704)
+++ trunk/gforge/www/include/trove.php	2009-05-28 20:07:03 UTC (rev 7705)
@@ -364,6 +364,35 @@
 	return $return;
 }
 
+/**
+ * trove_del_cat_id() - Delete the selected node (and its sub-nodes) in the trove tree
+ *
+ * @param		int		The node
+ */
+function trove_del_cat_id($node) {
+        $res=db_query("SELECT * FROM trove_cat WHERE parent='$node'");
+        if (!$res) {
+                exit_error( _('Error In Trove Operation'), db_error());
+        }
+        if (db_numrows($res)>0) {
+                for ($i=0; $i<db_numrows($res); $i++) {
+                        trove_del_cat_id(db_result($res,$i,'trove_cat_id'));
+                }
+	}
+        $res=db_query("DELETE FROM trove_treesums WHERE trove_cat_id='$node'");
+        if (!$res) {
+                exit_error( _('Error In Trove Operation'), db_error());
+        }
+        $res=db_query("DELETE FROM trove_group_link WHERE trove_cat_id='$node'");
+        if (!$res) {
+                exit_error( _('Error In Trove Operation'), db_error());
+        }
+        $res=db_query("DELETE FROM trove_cat WHERE trove_cat_id='$node'");
+        if (!$res || db_affected_rows($res)<1) {
+                exit_error( _('Error In Trove Operation'), db_error());
+        }
+}
+
 // Local Variables:
 // mode: php
 // c-file-style: "bsd"

Modified: trunk/tests/func/Site/AllTests.php
===================================================================
--- trunk/tests/func/Site/AllTests.php	2009-05-28 19:39:53 UTC (rev 7704)
+++ trunk/tests/func/Site/AllTests.php	2009-05-28 20:07:03 UTC (rev 7705)
@@ -53,7 +53,8 @@
 require_once dirname(__FILE__).'/projects.php';
 require_once dirname(__FILE__).'/top.php';
 require_once dirname(__FILE__).'/login.php';
- 
+require_once dirname(__FILE__).'/trove.php';
+
 class Site_AllTests
 {
     public static function main()
@@ -67,6 +68,7 @@
  
         $suite->addTestSuite('CreateProject');
         $suite->addTestSuite('LoginProcess');
+        $suite->addTestSuite('Trove');
         
         // FIXME: Do not run this test as it requires the cron to be launched
         //        $suite->addTestSuite('Top');

Added: trunk/tests/func/Site/trove.php
===================================================================
--- trunk/tests/func/Site/trove.php	                        (rev 0)
+++ trunk/tests/func/Site/trove.php	2009-05-28 20:07:03 UTC (rev 7705)
@@ -0,0 +1,74 @@
+<?php
+/*
+ * Copyright (C) 2009 Alain Peyrat <aljeux at free.fr>
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+require_once 'func/Testing/SeleniumGforge.php';
+
+class Trove extends FForge_SeleniumTestCase
+{
+	function testTroveAdmin()
+	{
+		$this->open( BASE );
+		$this->login('admin');
+		$this->click("link=Admin");
+		$this->waitForPageToLoad("30000");
+		$this->click("link=Display Trove Map");
+		$this->waitForPageToLoad("30000");
+
+		// Test simple modification of an entry (beta => beta2)
+		$this->click("//a[contains(@href, 'trove_cat_edit.php?trove_cat_id=10')]");
+		$this->waitForPageToLoad("30000");
+		$this->type("form_shortname", "beta2");
+		$this->type("form_fullname", "4 - Beta2");
+		$this->type("form_description", "Resource2 is in late phases of development. Deliverables are essentially complete, but may still have significant bugs.");
+		$this->click("submit");
+		$this->waitForPageToLoad("30000");
+		$this->assertTrue($this->isTextPresent("4 - Beta2"));
+
+		// Test removal of an entry (beta2) (leaf)
+		$this->click("//a[contains(@href, 'trove_cat_edit.php?trove_cat_id=10')]");
+		$this->waitForPageToLoad("30000");
+		$this->click("delete");
+		$this->waitForPageToLoad("30000");
+		$this->assertFalse($this->isTextPresent("4 - Beta2"));
+
+		// Test creation of a new entry (test)
+		$this->click("link=Admin");
+		$this->waitForPageToLoad("30000");
+		$this->click("link=Add to the Trove Map");
+		$this->waitForPageToLoad("30000");
+		$this->type("form_shortname", "Test");
+		$this->type("form_fullname", "Test");
+		$this->type("form_description", "This is a test");
+		$this->click("submit");
+		$this->waitForPageToLoad("30000");
+		$this->assertTrue($this->isTextPresent("Test"));
+
+		// Test removal of a non empty entry (Microsoft).
+		$this->click("//a[contains(@href, 'trove_cat_edit.php?trove_cat_id=214')]");
+		$this->waitForPageToLoad("30000");
+		$this->click("delete");
+		$this->waitForPageToLoad("30000");
+		$this->assertTrue($this->isTextPresent("Test"));
+		$this->assertFalse($this->isTextPresent("Microsoft"));
+	}
+}
+?>




More information about the Fusionforge-commits mailing list