misc
[phpeclipse.git] / net.sourceforge.phpeclipse.tests / src / net / sourceforge / phpeclipse / phpeditor / php / test / PHPFormatterTest.java
index 90ab589..8acbb51 100644 (file)
@@ -3,24 +3,31 @@
  *
  */
 package net.sourceforge.phpeclipse.phpeditor.php.test;
+
 import java.util.Map;
+
 import junit.framework.TestCase;
 import net.sourceforge.phpdt.core.JavaCore;
 import net.sourceforge.phpdt.internal.corext.codemanipulation.StubUtility;
 import net.sourceforge.phpdt.internal.corext.util.Strings;
 import net.sourceforge.phpdt.internal.formatter.CodeFormatter;
 import net.sourceforge.phpdt.internal.ui.preferences.CodeFormatterPreferencePage;
+
 import org.eclipse.jface.text.IDocument;
+
 /**
  * Testcase for the PHP CodeFormatter
  * 
  * @author Stefan Langer
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
  */
 public class PHPFormatterTest extends TestCase {
   private CodeFormatter fFormatter;
+
   private IDocument fDocument;
+
   private String fInitialIndentation;
+
   /*
    * (non-Javadoc)
    * 
@@ -31,6 +38,7 @@ public class PHPFormatterTest extends TestCase {
     fFormatter = new CodeFormatter(options);
     fDocument = new DummyDocument();
   }
+
   public void testFormatter0() {
     System.out.println("----- testFormatter0 -----");
     String text = "<?php\nheader(\"Location: http://www.phpeclipse.de/eclipse/space/eclipse/faq/longlinetester\"); exit; ?>";
@@ -38,16 +46,15 @@ public class PHPFormatterTest extends TestCase {
     String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument);
     int indent = 0;
     if (fInitialIndentation != null) {
-      indent = Strings.computeIndent(fInitialIndentation,
-          CodeFormatterPreferencePage.getTabSize());
+      indent = Strings.computeIndent(fInitialIndentation, CodeFormatterPreferencePage.getTabSize());
     }
-    String formatedString = fFormatter
-        .format(text, indent, null, lineDelimiter);
-    String testResult = "<?php " 
-        + lineDelimiter + "header(\"Location: http://www.phpeclipse.de/eclipse/space/eclipse/faq/longlinetester\");" + lineDelimiter
-        + "exit;" + lineDelimiter + "?>";
+    String formatedString = fFormatter.format(text, indent, null, lineDelimiter);
+    String testResult = "<?php " + lineDelimiter
+        + "header(\"Location: http://www.phpeclipse.de/eclipse/space/eclipse/faq/longlinetester\");" + lineDelimiter + "exit;"
+        + lineDelimiter + "?>";
     junit.framework.Assert.assertEquals(formatedString, testResult);
   }
+
   public void testFormatter1() {
     System.out.println("----- testFormatter1 -----");
     String text = "<?php\n" + "function test()\n" + "{echo 'Test!';}\n" + "?>";
@@ -55,49 +62,42 @@ public class PHPFormatterTest extends TestCase {
     String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument);
     int indent = 0;
     if (fInitialIndentation != null) {
-      indent = Strings.computeIndent(fInitialIndentation,
-          CodeFormatterPreferencePage.getTabSize());
+      indent = Strings.computeIndent(fInitialIndentation, CodeFormatterPreferencePage.getTabSize());
     }
-    String formatedString = fFormatter
-        .format(text, indent, null, lineDelimiter);
-    String testResult = "<?php "+ lineDelimiter + "function test() {" + lineDelimiter
-        + "\techo 'Test!';" + lineDelimiter + "}" + lineDelimiter + "?>";
+    String formatedString = fFormatter.format(text, indent, null, lineDelimiter);
+    String testResult = "<?php " + lineDelimiter + "function test() {" + lineDelimiter + "\techo 'Test!';" + lineDelimiter + "}"
+        + lineDelimiter + "?>";
     junit.framework.Assert.assertEquals(formatedString, testResult);
   }
+
   public void testFormatter2() {
     //  bug 741752
     System.out.println("----- testFormatter2 -----");
-    String text = "<?php\n" + "if ( ${ $feldname }== $modellvar) $i=0;\n"
-        + "?>";
+    String text = "<?php\n" + "if ( ${ $feldname }== $modellvar) $i=0;\n" + "?>";
     fDocument.set(text);
     String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument);
     int indent = 0;
     if (fInitialIndentation != null) {
-      indent = Strings.computeIndent(fInitialIndentation,
-          CodeFormatterPreferencePage.getTabSize());
+      indent = Strings.computeIndent(fInitialIndentation, CodeFormatterPreferencePage.getTabSize());
     }
-    String formatedString = fFormatter
-        .format(text, indent, null, lineDelimiter);
-    String testResult = "<?php " + lineDelimiter + "if (${ $feldname } == $modellvar)"
-        + lineDelimiter + "\t$i = 0;" + lineDelimiter + "?>";
+    String formatedString = fFormatter.format(text, indent, null, lineDelimiter);
+    String testResult = "<?php " + lineDelimiter + "if (${ $feldname } == $modellvar)" + lineDelimiter + "\t$i = 0;"
+        + lineDelimiter + "?>";
     junit.framework.Assert.assertEquals(formatedString, testResult);
   }
+
   public void testFormatter3() {
     System.out.println("----- testFormatter1 -----");
-    String text = "<?php\n \r\n \r\n" + "function test()\n"
-        + "{echo 'Test!';}\n" + "?>";
+    String text = "<?php\n \r\n \r\n" + "function test()\n" + "{echo 'Test!';}\n" + "?>";
     fDocument.set(text);
     String lineDelimiter = StubUtility.getLineDelimiterFor(fDocument);
     int indent = 0;
     if (fInitialIndentation != null) {
-      indent = Strings.computeIndent(fInitialIndentation,
-          CodeFormatterPreferencePage.getTabSize());
+      indent = Strings.computeIndent(fInitialIndentation, CodeFormatterPreferencePage.getTabSize());
     }
-    String formatedString = fFormatter
-        .format(text, indent, null, lineDelimiter);
-    String testResult = "<?php " + lineDelimiter + " " + lineDelimiter + " "
-        + lineDelimiter + "function test() {" + lineDelimiter
+    String formatedString = fFormatter.format(text, indent, null, lineDelimiter);
+    String testResult = "<?php " + lineDelimiter + " " + lineDelimiter + " " + lineDelimiter + "function test() {" + lineDelimiter
         + "\techo 'Test!';" + lineDelimiter + "}" + lineDelimiter + "?>";
     junit.framework.Assert.assertEquals(formatedString, testResult);
   }
-}
+}
\ No newline at end of file