1 package net.sourceforge.phpeclipse.tests.parser;
2 /*******************************************************************************
3 * Copyright (c) 2002 Klaus Hartlage - www.eclipseproject.de All rights
4 * reserved. This program and the accompanying materials are made available
5 * under the terms of the Common Public License v1.0 which accompanies this
6 * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html
7 ******************************************************************************/
8 import net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest;
9 import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
11 * Tests the php parser
13 public class OverlibTestCase extends AbstractCompilerTest {
15 public OverlibTestCase(String name) {
19 * Test the PHP Parser with different PHP snippets
21 public void testPHPParser() {
26 " This is version 1.11 of class.overlib for php (http://www.php.net) \r\n" +
28 " written 1999, 2000, 2001 Patrick Hess <hess@dland.de>\r\n" +
30 " This software is distributed under GPL.\r\n" +
32 " overLib is from Eric Bosrup (http://www.bosrup.com/web/overlib/)\r\n" +
34 " This class is just a driver/container, so most of this wonderful\r\n" +
36 " work is done by Eric Bosrup! Keep this in mind... \r\n" +
42 " class Overlib {\r\n" +
44 " public $ol_path = \"modules/Forums\";\r\n" +
46 " public $ol_sticky = false;\r\n" +
48 " public $ol_align = 0;\r\n" +
50 " public $ol_valign = 0;\r\n" +
52 " public $ol_fgcolor = \"#fcfcfc\";\r\n" +
54 " public $ol_bgcolor = \"#0080C0\";\r\n" +
56 " public $ol_capcolor = \"#ffffff\";\r\n" +
58 " public $ol_textcolor = \"\";\r\n" +
60 " public $ol_closecolor = \"\";\r\n" +
62 " public $ol_textfont = \"\";\r\n" +
64 " public $ol_captionfont = \"\";\r\n" +
66 " public $ol_closefont = \"\";\r\n" +
68 " public $ol_textsize = 0;\r\n" +
70 " public $ol_captionsize = 0;\r\n" +
72 " public $ol_closesize = 0;\r\n" +
74 " public $ol_height = 0;\r\n" +
76 " public $ol_width = 0;\r\n" +
78 " public $ol_border = 3;\r\n" +
80 " public $ol_offsetx = 0;\r\n" +
82 " public $ol_offsety = 0;\r\n" +
84 " public $ol_fgbackground = \"\";\r\n" +
86 " public $ol_bgbackground = \"\";\r\n" +
88 " public $ol_closetext = \"Close\";\r\n" +
90 " public $ol_close = true;\r\n" +
92 " public $ol_noclosetext = false;\r\n" +
94 " public $ol_autostatus = false;\r\n" +
96 " public $ol_autostatuscap = false;\r\n" +
98 " public $ol_capicon = \"images/forum/question.gif\";\r\n" +
100 " public $ol_snapx = 0;\r\n" +
102 " public $ol_snapy = 0;\r\n" +
104 " public $ol_padxl = 0;\r\n" +
106 " public $ol_padxr = 0;\r\n" +
108 " public $ol_padyt = 0;\r\n" +
110 " public $ol_padyb = 0;\r\n" +
112 " public $ol_fixy = 0;\r\n" +
114 " public $ol_background = \"\";\r\n" +
116 " public $ol_fullhtml = false;\r\n" +
118 " public $ol_timeout = -1;\r\n" +
120 " public $ol_delay = -1;\r\n" +
122 " public $ol_vauto = false;\r\n" +
124 " public $ol_hauto = false;\r\n" +
128 " function overLib($path = \"\") {\r\n" +
130 " if (strlen($path)) $this->ol_path = $path;\r\n" +
134 "<nolink rel=\'stylesheet\' href=<?php echo \"\'$this->ol_path/overlib.css\' \"; ?> \r\n" +
136 " type=\'text/css\'>\r\n" +
138 "<div id=\'overDiv\' style=\'position:absolute; visibility:hide; z-index: 1000;\'>\r\n" +
142 "<script language=\'javascript\' src=<?php echo \"\'$this->ol_path/overlib.js\'\"; ?>>\r\n" +
152 " function set($var, $value) {\r\n" +
154 " $v = \"ol_$var\";\r\n" +
156 " $this->$v = $value;\r\n" +
162 " function get($var) {\r\n" +
164 " $v = \"ol_$var\";\r\n" +
166 " return($this->$v);\r\n" +
172 " function over($text, $title = \"\", $status = \"\")\r\n" +
176 " $cmd = \"\'$text\'\";\r\n" +
180 " if(strlen($title)) \r\n" +
182 " $cmd .= \", CAPTION, \'$title\'\";\r\n" +
186 " if(strlen($status)) \r\n" +
188 " $cmd .= \", STATUS, \'$status\'\";\r\n" +
192 " if($this->ol_sticky) \r\n" +
194 " $cmd .= \", STICKY\";\r\n" +
198 " if($this->ol_align) {\r\n" +
200 " switch($this->ol_align) {\r\n" +
202 " case 1: $cmd .= \", LEFT\"; break;\r\n" +
204 " case 2: $cmd .= \", CENTER\"; break;\r\n" +
206 " case 3: $cmd .= \", RIGHT\"; break;\r\n" +
208 " default: break;\r\n" +
216 " if($this->ol_valign) {\r\n" +
218 " switch($this->ol_valign) {\r\n" +
220 " case 1: $cmd .= \", ABOVE\"; break;\r\n" +
222 " case 2: $cmd .= \", BELOW\"; break;\r\n" +
224 " default: break;\r\n" +
232 " if (strlen($this->ol_fgbackground)) {\r\n" +
234 " $cmd .= \", FGCOLOR, \'\', FGBACKGROUND, \'$this->ol_fgbackground\'\";\r\n" +
238 " if (strlen($this->ol_fgcolor))\r\n" +
240 " $cmd .= \", FGCOLOR, \'$this->ol_fgcolor\'\";\r\n" +
246 " if (strlen($this->ol_bgbackground)) {\r\n" +
248 " $cmd .= \", BGCOLOR, \'\', BGBACKGROUND, \'$this->ol_bgbackground\'\";\r\n" +
252 " if (strlen($this->ol_bgcolor))\r\n" +
254 " $cmd .= \", BGCOLOR, \'$this->ol_bgcolor\'\";\r\n" +
260 " if (strlen($this->ol_capcolor))\r\n" +
262 " $cmd .= \", CAPCOLOR, \'$this->ol_capcolor\'\";\r\n" +
266 " if (strlen($this->ol_textcolor))\r\n" +
268 " $cmd .= \", TEXTCOLOR, \'$this->ol_textcolor\'\";\r\n" +
272 " if (strlen($this->ol_closecolor))\r\n" +
274 " $cmd .= \", CLOSECOLOR, \'$this->ol_closecolor\'\";\r\n" +
278 " if (strlen($this->ol_textfont))\r\n" +
280 " $cmd .= \", TEXTFONT, \'$this->ol_textfont\'\";\r\n" +
284 " if (strlen($this->ol_captionfont))\r\n" +
286 " $cmd .= \", CAPTIONFONT, \'$this->ol_captionfont\'\";\r\n" +
290 " if (strlen($this->ol_closefont))\r\n" +
292 " $cmd .= \", CLOSEFONT, \'$this->ol_closefont\'\";\r\n" +
296 " if ($this->ol_textsize)\r\n" +
298 " $cmd .= \", TEXTSIZE, $this->ol_textsize\";\r\n" +
302 " if ($this->ol_captionsize)\r\n" +
304 " $cmd .= \", CAPTIONSIZE, $this->ol_captionsize\";\r\n" +
308 " if ($this->ol_closesize)\r\n" +
310 " $cmd .= \", CLOSESIZE, $this->ol_closesize\";\r\n" +
314 " if ($this->ol_width)\r\n" +
316 " $cmd .= \", WIDTH, $this->ol_width\";\r\n" +
320 " if ($this->ol_height)\r\n" +
322 " $cmd .= \", HEIGHT, $this->ol_height\";\r\n" +
326 " if ($this->ol_border >= 0)\r\n" +
328 " $cmd .= \", BORDER, $this->ol_border\";\r\n" +
332 " if ($this->ol_offsetx)\r\n" +
334 " $cmd .= \", OFFSETX, $this->ol_offsetx\";\r\n" +
338 " if ($this->ol_offsety)\r\n" +
340 " $cmd .= \", OFFSETY, $this->ol_offsety\";\r\n" +
344 " if (strlen($this->ol_closetext))\r\n" +
346 " $cmd .= \", CLOSETEXT, \'$this->ol_closetext\'\";\r\n" +
350 " if ($this->ol_noclose)\r\n" +
352 " $cmd .= \", NOCLOSETEXT\";\r\n" +
356 " if ($this->ol_autostatus)\r\n" +
358 " $cmd .= \", AUTOSTATUS\";\r\n" +
362 " if ($this->ol_autostatuscap)\r\n" +
364 " $cmd .= \", AUTOSTATUSCAP\";\r\n" +
368 " if (strlen($this->ol_capicon))\r\n" +
370 " $cmd .= \", CAPICON, \'$this->ol_capicon\'\";\r\n" +
374 " if ($this->ol_snapx)\r\n" +
376 " $cmd .= \", SNAPX, $this->ol_snapx\";\r\n" +
380 " if ($this->ol_snapy)\r\n" +
382 " $cmd .= \", SNAPY, $this->ol_snapy\";\r\n" +
386 " if ($this->ol_fixy)\r\n" +
388 " $cmd .= \", FIXY, $this->ol_fixy\";\r\n" +
392 " if ($this->ol_padxl || $this->ol_padxr)\r\n" +
394 " $cmd .= \", PADX, $this->ol_padxl, $this->ol_padxr\";\r\n" +
398 " if ($this->ol_padyt || $this->ol_padyb)\r\n" +
400 " $cmd .= \", PADY, $this->ol_padyt, $this->ol_padyb\";\r\n" +
404 " if (strlen($this->ol_background))\r\n" +
406 " $cmd .= \", BACKGROUND, \'$this->ol_background\'\";\r\n" +
410 " if ($this->ol_fullhtml)\r\n" +
412 " $cmd .= \", FULLHTML\";\r\n" +
416 " if ($this->ol_timeout >= 0)\r\n" +
418 " $cmd .= \", TIMEOUT, $this->ol_timeout\";\r\n" +
422 " if ($this->ol_delay >= 0)\r\n" +
424 " $cmd .= \", DELAY, $this->ol_delay\";\r\n" +
428 " if ($this->ol_hauto) {\r\n" +
430 " $cmd .= \", HAUTO\";\r\n" +
432 " $this->ol_hauto = false;\r\n" +
438 " if ($this->ol_vauto) {\r\n" +
440 " $cmd .= \", VAUTO\";\r\n" +
442 " $this->ol_hauto = false;\r\n" +
448 " $output=\" onMouseOver=\\\"return overlib($cmd);\\\" \";\r\n" +
450 " $output.=\" onMouseOut=\\\"nd();\\\" \";\r\n" +
454 " return ($output);\r\n" +
460 " function pover ($text, $title = \"\", $status = \"\") \r\n" +
464 " echo $this->over($text, $title, $status);\r\n" +
478 private void checkPHP(String strEval) {
480 System.out.println("\n------------------------------------");
481 System.out.println(strEval);
484 strEval.toCharArray(),
486 // parser.phpParserTester(strEval, 1);
488 private void checkHTML(String strEval) {
490 System.out.println("\n------------------------------------");
491 System.out.println(strEval);
494 strEval.toCharArray(),
496 // parser.phpParserTester(strEval, 1);
498 // private void checkHTML(String strEval) {
499 // if (Scanner.DEBUG) {
500 // System.out.println("\n------------------------------------");
501 // System.out.println(strEval);
503 // parser.parse(strEval);
506 // * The JUnit setup method
508 // protected void setUp() {
509 // parser = new Parser(null);