bug 1365831, error for creating new file with empty new PHP file template
[phpeclipse.git] / net.sourceforge.phpeclipse.phpunit / src / net / sourceforge / phpeclipse / phpunit / testpool / TestPool.java
index 008cb3d..8e6a7fb 100644 (file)
@@ -1,22 +1,17 @@
-/*
- * Created on Jul 31, 2004
+/*************************************************************************
+ * @author Ali Echihabi (ali_echihabi@ieee.org, ali.echihabi@souss.ca)
  *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
+ * Plugin for PHP unit Testing.
+ * www.phpeclipse.de
+ * 
+ *************************************************************************/
+
+
 package net.sourceforge.phpeclipse.phpunit.testpool;
 
 import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Vector;
 
-
-/**
- * @author Ali Echihabi
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
 public class TestPool {
 
        //private TestSuite currentParentTestSuite;
@@ -31,8 +26,7 @@ public class TestPool {
        public TestPool(String rootTitle) {
                
                tests = new HashMap();
-               root = new TestSuite(rootTitle, "-1", 0);
-               
+               root = null;            
                currentTestSuite = root;
                
        }
@@ -62,11 +56,19 @@ public class TestPool {
         */
        public void addTestSuite(TestSuite suite) {
        
-       //add as sibling
-               currentTestSuite.addTestSuite(suite);
-               suite.setParent(currentTestSuite);
-
-               currentTestSuite = suite;
+       
+       if(root == null) {
+               root = suite;
+       } 
+       else {
+       
+               //add as sibling        
+                       currentTestSuite.addTestSuite(suite);
+                       suite.setParent(currentTestSuite);
+
+       }       
+       
+               currentTestSuite = suite;       
        }
 
        /**
@@ -107,22 +109,12 @@ public class TestPool {
        
        }
 
-       private int countSuiteExpectedTests(TestSuite suite) {
-               
-               int total = 0;
-               
-               total += suite.getNumTestCasesExpected();
-               
-               for(int i = 0; i < suite.getTestSuites().size(); i++) 
-                       total += countSuiteExpectedTests((TestSuite) suite.getTestSuites().elementAt(i));
-               
-               return total;
-       
-       }
 
        public int getNumTestsOverall() {
        
-               return countSuiteExpectedTests(root);
+               int total = root.getNumTestCasesExpected();
+               System.out.println("total: " + total);
+               return total;
                                
        }
        
@@ -137,19 +129,19 @@ public class TestPool {
                
                int total = 0;
                
-               Iterator i = tests.keySet().iterator();
-               String key = "";
-               while (i.hasNext()) {
-                       
-                       
-                       key = (String) i.next();
-                       TestCase element = (TestCase) tests.get(key);
-                       
-                       
-                       if(element.isFailure())
-                               total++;
-                       
-               }
+//             Iterator i = tests.keySet().iterator();
+//             String key = "";
+//             while (i.hasNext()) {
+//                     
+//                     
+//                     key = (String) i.next();
+//                     TestCase element = (TestCase) tests.get(key);
+//                     
+//                     
+//                     if(element.isFailure())
+//                             total++;
+//                     
+//             }
                        
                return total;
        }