* 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 junit.framework.TestCase;
-import net.sourceforge.phpdt.internal.compiler.parser.Parser;
+import net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest;
import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
/**
* Tests the php parser
*/
-public class PHPParserTestCase extends TestCase {
- Parser parser;
+public class PHPParserTestCase extends AbstractCompilerTest {
+// Parser parser;
public PHPParserTestCase(String name) {
super(name);
}
* Test the PHP Parser with different PHP snippets
*/
public void testPHPParser() {
+ checkHTML("<?php if ($a==$b) {\n" +
+ "}\n" +
+ ""+
+ "?> ");
+ checkHTML("<?php if ($a==$b) {?>\n" +
+ "<b>test <?php echo \"test\";?> me</b>\n" +
+ "<?php } \n" +
+ "echo $bgcolor2 ?>");
+
+ checkHTML("<?php echo $bgcolor2 ?>");
+ checkPHP("function clean_words($mode, &$entry, &$stopword_list, &$synonym_list)\r\n" +
+ "{ static $drop_char_match = array(\'^\', \'$\'); }");
+
+ checkPHP("if ($topic<1) { $topic = 1;}");
+ checkPHP("$this->result_field_names[$result_id][] = odbc_field_name($result_id, $i);");
+ checkPHP("$db->sql_query($sql);");
+ checkPHP("$val = $$add;");
// checkPHP("if(!$result = mysql_query($sql)) return(array());");
checkPHP("class test { function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) \n{ \n } \n }");
// Bugs item #690938
checkPHP("@$connect_function($dbhost, $user, $pw);");
checkPHP("$conn = @$connect_function($dbhost, $user, $pw);");
checkPHP("global ${$objectname}; ");
- checkPHP("class DB_mssql extends DB_common { var $connection; var $phptype, $dbsyntax; } ");
+ // checkPHP("class DB_mssql extends DB_common { var $connection; var $phptype, $dbsyntax; } ");
checkPHP("unset($this->blockvariables[$block][$varname]);");
checkPHP("new IT_Error(\"The block '$block' was not found in the template.\", __FILE__, __LINE__);");
checkPHP("for ($i=156, $j=0; $i<512; $i++, $j++) $v_checksum += ord(substr($v_binary_data_last,$j,1));");
checkPHP("function validateAndParseResponse($code, &$arguments) { }");
checkPHP("$options = Console_Getopt::getopt($argv, \"h?v:e:p:d:\");");
checkPHP("$this->container = new $container_class($container_options);");
- checkPHP("class Cmd extends PEAR { var $arrSetting = array(); }");
- checkPHP("class Cmd extends PEAR { var $arrSetting = array(), $i=10; }");
+ // checkPHP("class Cmd extends PEAR { var $arrSetting = array(); }");
+ // checkPHP("class Cmd extends PEAR { var $arrSetting = array(), $i=10; }");
checkPHP("if (isset($test)) { } elseif (isset($lang)) { }");
checkPHP("require_once(\"mainfile.php\"); ");
checkPHP("if (eregi(\"footer.php\",$PHP_SELF)) {\n"
checkPHP("do {$array[] = array(\"$myrow[uid]\" => \"$myrow[uname]\"); } while($myrow = mysql_fetch_array($result));");
checkPHP("$ol = new Overlib();");
checkPHP("$risultato = mysql_query($sql) or\n die(mysql_error());");
- checkHTML("\n\n\n\n <?php print \"Hello world\" ?>");
- checkHTML("<?php phpinfo(); ?>");
- checkHTML("<?php phpinfo()?>");
- checkHTML("<?php phpinfo(); ?> foo <?php phpinfo(); ?>");
- checkHTML(" <?php //this is a line comment ?>");
- checkHTML("<?php echo $module_name ?>");
+// checkHTML("\n\n\n\n <?php print \"Hello world\" ?>");
+// checkHTML("<?php phpinfo(); ?>");
+// checkHTML("<?php phpinfo()?>");
+// checkHTML("<?php phpinfo(); ?> foo <?php phpinfo(); ?>");
+// checkHTML(" <?php //this is a line comment ?>");
+// checkHTML("<?php echo $module_name ?>");
}
private void checkPHP(String strEval) {
if (Scanner.DEBUG) {
System.out.println("\n------------------------------------");
System.out.println(strEval);
}
- parser.phpParserTester(strEval, 1);
+ checkParsePHP(
+ strEval.toCharArray(),
+ "");
+// parser.phpParserTester(strEval, 1);
}
private void checkHTML(String strEval) {
if (Scanner.DEBUG) {
System.out.println("\n------------------------------------");
System.out.println(strEval);
}
- parser.parse(strEval);
- }
- /**
- * The JUnit setup method
- */
- protected void setUp() {
- parser = new Parser(null);
+ checkParseHTML(
+ strEval.toCharArray(),
+ "");
+// parser.phpParserTester(strEval, 1);
}
+// private void checkHTML(String strEval) {
+// if (Scanner.DEBUG) {
+// System.out.println("\n------------------------------------");
+// System.out.println(strEval);
+// }
+// parser.parse(strEval);
+// }
+// /**
+// * The JUnit setup method
+// */
+// protected void setUp() {
+// parser = new Parser(null);
+// }
}