package test;
+
/**********************************************************************
-Copyright (c) 2002 Klaus Hartlage - www.eclipseproject.de
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-**********************************************************************/
+ Copyright (c) 2002 Klaus Hartlage - www.eclipseproject.de
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Common Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/cpl-v10.html
+ **********************************************************************/
import org.eclipse.core.runtime.CoreException;
import junit.framework.TestCase;
import java.io.CharArrayReader;
+import java.io.File;
/**
* Test the PHP Parser with different PHP snippets
*/
public void testPHPParser() {
- checkHTML("<?php" +
- "\n//if (!isset($AtreidesLanguage)) $AtreidesLanguage='french';" +
- "\n$AtreidesLanguage='french';" +
- "\n$for = 1;" +
- "\n\ninclude_once('php/template.inc');" +
- "\ninclude ' php/class.PHPLIBTemplateAdaptor.php';" +
- "\ninclude 'php/class.CachedTemplate.php';" +
- "\n$_PHPLIB['libdir']='php/';" +
- "\ninclude 'php/oohforms.inc';" +
- "\n include 'objet/outil.php';" +
- "\ninclude 'objet/metier.php';" +
- "\ninclude 'php/db_mysql.inc';" +
- "\ninclude 'objet/db5.php';" +
- "\ninclude 'objet/gui.php';" +
- "\ninclude 'objet/application.php';" +
- "\n//----------------------------------------------------" +
- "\n// Objets du site" +
- "\n//----------------------------------------------------" +
- "\n// Objets de base de donnée" +
- "\ninclude 'atreides/db_soft.php';" +
- "\n// Objets metier" +
- "\ninclude 'atreides/soft.php';" +
- "\n// Objets application" +
- "\ninclude 'atreides/atreides.php';" +
- "\n$AtreidesTheme='normal/$AtreidesLanguage';" +
- "\nif(Vide($oCentral)) $oCentral='Soft';" +
- "\nif (vide($oModeCentral)) $oModeCentral = 'recherche';" +
- "\nif (Vide($theme)) $theme='normal';" +
- "\nif (Vide($mode)) $mode='visu';" +
- "\n$Atreides=new Atreides($mode,$ini);" +
- "\n$Atreides->tabAffich['oModeCentral']=$oModeCentral;" +
- "\nob_start('ob_gzhandler');" +
- "\necho $Atreides->vueMetier('visu',$AtreidesTheme);" +
+ //checkHTML(new File("class.adm_gestuser.php"));
+ checkHTML("<?php function f($a,$b) {" +
+ "echo $a; } ?>");
+ checkHTML("<?php ec ho 'coucou'; ?>" +
+ "\n dfgdfgfdfg" +
+ "\n" +
+ "\n" +
+ "<?php" +
+ "\necho ' caca';" +
+ "\n?>" +
+ "dfgdfg" +
+ "\ndsfgdf");
+ checkHTML("<?php echo 'coucou'; ?>" +
+ "\n dfgdfgfdfg" +
+ "\n" +
+ "\n" +
+ "<?php" +
+ "\necho ' caca';" +
"\n?>");
checkHTML("<html>sdfsdf <?php phpinfo(); ?>");
checkHTML("\n\n\n\n <?php print \"Hello world\"?> ");
checkPHP("$AllowableHTML = array(\"b\"=>1,\n \"i\"=>1);");
checkPHP("if ($term{0}!=$firstChar) {}");
checkPHP(
- "echo \"<center><b>\"._NOADMINYET.\"</b></center><br><br>\"\n"
+ "echo \"<center><b>\"._NOADMINYET.\"</b></center><br><br>\"\n"
+ ".\"<form action=\\\"admin.php\\\" method=\\\"post\\\">\"\n"
+ ".\"<tr><td><b>\"._NICKNAME.\":</b></td><td><input type=\\\"text\\\" name=\\\"name\\\" size=\\\"30\\\" maxlength=\\\"25\\\"></td></tr>\"\n"
+ ";");
checkPHP("if ($arrAtchCookie[1]==0 && $IdAtchPostId!=null){ } ");
checkPHP("$arrAtchCookie[1] -= filesize(realpath($AtchTempDir).\"/\".$xattachlist)/ 1024; ");
checkPHP(
- "if (!isset($message)){ \n"
+ "if (!isset($message)){ \n"
+ "$message = $myrow[post_text];\n"
+ "$message = eregi_replace(\"\\[addsig]\", \"\\n-----------------\\n\" . $myrow[user_sig], $message); \n"
+ "$message = str_replace(\"<BR>\", \"\\n\", $message); \n"
}
}
+
private void checkHTML(String strEval) {
try {
System.out.println("strEval = " + strEval);
}
+ private void checkHTML(File strEval) {
+ try {
+ System.out.println("strEval = " + strEval.toString());
+ parser.htmlParserTester(strEval);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+
+ }
+
/**
* The JUnit setup method
*/