6f4cb49a3f2b5841ffe94aae2e77ebd851c3914c
[phpeclipse.git] / net.sourceforge.phpeclipse.tests / src / net / sourceforge / phpeclipse / tests / parser / OverlibTestCase.java
1 package net.sourceforge.phpeclipse.tests.parser;
2 /*******************************************************************************
3  * Copyright (c) 2002 www.phpeclipse.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;
10 /**
11  * Tests the php parser
12  */
13 public class OverlibTestCase extends AbstractCompilerTest {
14 //  Parser parser;
15   public OverlibTestCase(String name) {
16     super(name);
17   }
18   /**
19    * Test the PHP Parser with different PHP snippets
20    */
21   public void testPHPParser() {
22     checkPHP(
23                 "\r\n" + 
24                 "    /*\r\n" + 
25                 "\r\n" + 
26                 "       This is version 1.11 of class.overlib for php (http://www.php.net) \r\n" + 
27                 "\r\n" + 
28                 "       written 1999, 2000, 2001 Patrick Hess <hess@dland.de>\r\n" + 
29                 "\r\n" + 
30                 "       This software is distributed under GPL.\r\n" + 
31                 " \r\n" + 
32                 "       overLib is from Eric Bosrup (http://www.bosrup.com/web/overlib/)\r\n" + 
33                 "\r\n" + 
34                 "       This class is just a driver/container, so most of this wonderful\r\n" + 
35                 " \r\n" + 
36                 "       work is done by Eric Bosrup! Keep this in mind... \r\n" + 
37                 "\r\n" + 
38                 "    */\r\n" + 
39                 "\r\n" + 
40                 "\r\n" + 
41                 "\r\n" + 
42                 "       class Overlib {\r\n" + 
43                 "\r\n" + 
44                 "         public $ol_path          = \"modules/Forums\";\r\n" + 
45                 "\r\n" + 
46                 "         public $ol_sticky        = false;\r\n" + 
47                 "\r\n" + 
48                 "         public $ol_align              = 0;\r\n" + 
49                 "\r\n" + 
50                 "         public $ol_valign        = 0;\r\n" + 
51                 "\r\n" + 
52                 "         public $ol_fgcolor       = \"#fcfcfc\";\r\n" + 
53                 "\r\n" + 
54                 "         public $ol_bgcolor       = \"#0080C0\";\r\n" + 
55                 "\r\n" + 
56                 "         public $ol_capcolor      = \"#ffffff\";\r\n" + 
57                 "\r\n" + 
58                 "         public $ol_textcolor     = \"\";\r\n" + 
59                 "\r\n" + 
60                 "         public $ol_closecolor    = \"\";\r\n" + 
61                 "\r\n" + 
62                 "         public $ol_textfont      = \"\";\r\n" + 
63                 "\r\n" + 
64                 "         public $ol_captionfont   = \"\";\r\n" + 
65                 "\r\n" + 
66                 "         public $ol_closefont     = \"\";\r\n" + 
67                 "\r\n" + 
68                 "         public $ol_textsize      = 0;\r\n" + 
69                 "\r\n" + 
70                 "         public $ol_captionsize   = 0;\r\n" + 
71                 "\r\n" + 
72                 "         public $ol_closesize     = 0;\r\n" + 
73                 "\r\n" + 
74                 "         public $ol_height        = 0;\r\n" + 
75                 "\r\n" + 
76                 "         public $ol_width         = 0;\r\n" + 
77                 "\r\n" + 
78                 "         public $ol_border        = 3;\r\n" + 
79                 "\r\n" + 
80                 "         public $ol_offsetx       = 0;\r\n" + 
81                 "\r\n" + 
82                 "         public $ol_offsety       = 0;\r\n" + 
83                 "\r\n" + 
84                 "         public $ol_fgbackground  = \"\";\r\n" + 
85                 "\r\n" + 
86                 "         public $ol_bgbackground  = \"\";\r\n" + 
87                 "\r\n" + 
88                 "         public $ol_closetext     = \"Close\";\r\n" + 
89                 "\r\n" + 
90                 "         public $ol_close         = true;\r\n" + 
91                 "\r\n" + 
92                 "         public $ol_noclosetext   = false;\r\n" + 
93                 "\r\n" + 
94                 "         public $ol_autostatus    = false;\r\n" + 
95                 "\r\n" + 
96                 "         public $ol_autostatuscap = false;\r\n" + 
97                 "\r\n" + 
98                 "         public $ol_capicon       = \"images/forum/question.gif\";\r\n" + 
99                 "\r\n" + 
100                 "         public $ol_snapx         = 0;\r\n" + 
101                 "\r\n" + 
102                 "         public $ol_snapy         = 0;\r\n" + 
103                 "\r\n" + 
104                 "         public $ol_padxl         = 0;\r\n" + 
105                 "\r\n" + 
106                 "         public $ol_padxr         = 0;\r\n" + 
107                 "\r\n" + 
108                 "         public $ol_padyt         = 0;\r\n" + 
109                 "\r\n" + 
110                 "         public $ol_padyb         = 0;\r\n" + 
111                 "\r\n" + 
112                 "         public $ol_fixy          = 0;\r\n" + 
113                 "\r\n" + 
114                 "         public $ol_background    = \"\";\r\n" + 
115                 "\r\n" + 
116                 "         public $ol_fullhtml      = false;\r\n" + 
117                 "\r\n" + 
118                 "         public $ol_timeout    = -1;\r\n" + 
119                 "\r\n" + 
120                 "         public $ol_delay              = -1;\r\n" + 
121                 "\r\n" + 
122                 "         public $ol_vauto         = false;\r\n" + 
123                 "\r\n" + 
124                 "         public $ol_hauto         = false;\r\n" + 
125                 "\r\n" + 
126                 "\r\n" + 
127                 "\r\n" + 
128                 "         function overLib($path = \"\") {\r\n" + 
129                 "\r\n" + 
130                 "               if (strlen($path)) $this->ol_path = $path;\r\n" + 
131                 "\r\n" + 
132                 "?>\r\n" + 
133                 "\r\n" + 
134                 "<nolink rel=\'stylesheet\' href=<?php echo \"\'$this->ol_path/overlib.css\' \"; ?> \r\n" + 
135                 "\r\n" + 
136                 "      type=\'text/css\'>\r\n" + 
137                 "\r\n" + 
138                 "<div id=\'overDiv\' style=\'position:absolute; visibility:hide; z-index: 1000;\'>\r\n" + 
139                 "\r\n" + 
140                 "</div>\r\n" + 
141                 "\r\n" + 
142                 "<script language=\'javascript\' src=<?php echo \"\'$this->ol_path/overlib.js\'\"; ?>>\r\n" + 
143                 "\r\n" + 
144                 "</script>\r\n" + 
145                 "\r\n" + 
146                 "<?php\r\n" + 
147                 "\r\n" + 
148                 "         }  \r\n" + 
149                 "       \r\n" + 
150                 " \r\n" + 
151                 "\r\n" + 
152                 "         function set($var, $value) {\r\n" + 
153                 "\r\n" + 
154                 "               $v = \"ol_$var\";\r\n" + 
155                 "\r\n" + 
156                 "               $this->$v = $value;\r\n" + 
157                 "\r\n" + 
158                 "         }\r\n" + 
159                 "\r\n" + 
160                 "\r\n" + 
161                 "\r\n" + 
162                 "         function get($var) {\r\n" + 
163                 "\r\n" + 
164                 "               $v = \"ol_$var\";\r\n" + 
165                 "\r\n" + 
166                 "               return($this->$v);\r\n" + 
167                 "\r\n" + 
168                 "         }\r\n" + 
169                 "\r\n" + 
170                 "\r\n" + 
171                 "\r\n" + 
172                 "         function over($text, $title = \"\", $status = \"\")\r\n" + 
173                 "\r\n" + 
174                 "         {\r\n" + 
175                 "\r\n" + 
176                 "           $cmd = \"\'$text\'\";\r\n" + 
177                 "\r\n" + 
178                 "\r\n" + 
179                 "\r\n" + 
180                 "           if(strlen($title)) \r\n" + 
181                 "\r\n" + 
182                 "               $cmd .= \", CAPTION, \'$title\'\";\r\n" + 
183                 "\r\n" + 
184                 "\r\n" + 
185                 "\r\n" + 
186                 "           if(strlen($status)) \r\n" + 
187                 "\r\n" + 
188                 "               $cmd .= \", STATUS, \'$status\'\";\r\n" + 
189                 "\r\n" + 
190                 "\r\n" + 
191                 "\r\n" + 
192                 "           if($this->ol_sticky)        \r\n" + 
193                 "\r\n" + 
194                 "               $cmd .= \", STICKY\";\r\n" + 
195                 "\r\n" + 
196                 "\r\n" + 
197                 "\r\n" + 
198                 "           if($this->ol_align) {\r\n" + 
199                 "\r\n" + 
200                 "               switch($this->ol_align) {\r\n" + 
201                 "\r\n" + 
202                 "                   case 1: $cmd .= \", LEFT\"; break;\r\n" + 
203                 "\r\n" + 
204                 "                   case 2: $cmd .= \", CENTER\";       break;\r\n" + 
205                 "\r\n" + 
206                 "                   case 3: $cmd .= \", RIGHT\";        break;\r\n" + 
207                 "\r\n" + 
208                 "                   default:                    break;\r\n" + 
209                 "\r\n" + 
210                 "               }\r\n" + 
211                 "\r\n" + 
212                 "           }\r\n" + 
213                 "\r\n" + 
214                 "\r\n" + 
215                 "\r\n" + 
216                 "           if($this->ol_valign) {\r\n" + 
217                 "\r\n" + 
218                 "               switch($this->ol_valign) {\r\n" + 
219                 "\r\n" + 
220                 "                   case 1: $cmd .= \", ABOVE\";        break;\r\n" + 
221                 "\r\n" + 
222                 "                   case 2: $cmd .= \", BELOW\";        break;\r\n" + 
223                 "\r\n" + 
224                 "                   default:                    break;\r\n" + 
225                 "\r\n" + 
226                 "               }\r\n" + 
227                 "\r\n" + 
228                 "           }\r\n" + 
229                 "\r\n" + 
230                 "\r\n" + 
231                 "\r\n" + 
232                 "           if (strlen($this->ol_fgbackground)) {\r\n" + 
233                 "\r\n" + 
234                 "               $cmd .= \", FGCOLOR, \'\', FGBACKGROUND, \'$this->ol_fgbackground\'\";\r\n" + 
235                 "\r\n" + 
236                 "           } else {\r\n" + 
237                 "\r\n" + 
238                 "               if (strlen($this->ol_fgcolor))\r\n" + 
239                 "\r\n" + 
240                 "                       $cmd .= \", FGCOLOR, \'$this->ol_fgcolor\'\";\r\n" + 
241                 "\r\n" + 
242                 "           }\r\n" + 
243                 "\r\n" + 
244                 "\r\n" + 
245                 "\r\n" + 
246                 "           if (strlen($this->ol_bgbackground)) {\r\n" + 
247                 "\r\n" + 
248                 "               $cmd .= \", BGCOLOR, \'\', BGBACKGROUND, \'$this->ol_bgbackground\'\";\r\n" + 
249                 "\r\n" + 
250                 "           } else {\r\n" + 
251                 "\r\n" + 
252                 "               if (strlen($this->ol_bgcolor))\r\n" + 
253                 "\r\n" + 
254                 "                       $cmd .= \", BGCOLOR, \'$this->ol_bgcolor\'\";\r\n" + 
255                 "\r\n" + 
256                 "           }\r\n" + 
257                 "\r\n" + 
258                 "\r\n" + 
259                 "\r\n" + 
260                 "           if (strlen($this->ol_capcolor))\r\n" + 
261                 "\r\n" + 
262                 "               $cmd .= \", CAPCOLOR, \'$this->ol_capcolor\'\";\r\n" + 
263                 "\r\n" + 
264                 "\r\n" + 
265                 "\r\n" + 
266                 "           if (strlen($this->ol_textcolor))\r\n" + 
267                 "\r\n" + 
268                 "               $cmd .= \", TEXTCOLOR, \'$this->ol_textcolor\'\";\r\n" + 
269                 "\r\n" + 
270                 "\r\n" + 
271                 "\r\n" + 
272                 "           if (strlen($this->ol_closecolor))\r\n" + 
273                 "\r\n" + 
274                 "               $cmd .= \", CLOSECOLOR, \'$this->ol_closecolor\'\";\r\n" + 
275                 "\r\n" + 
276                 "\r\n" + 
277                 "\r\n" + 
278                 "           if (strlen($this->ol_textfont))\r\n" + 
279                 "\r\n" + 
280                 "               $cmd .= \", TEXTFONT, \'$this->ol_textfont\'\";\r\n" + 
281                 "\r\n" + 
282                 "\r\n" + 
283                 "\r\n" + 
284                 "           if (strlen($this->ol_captionfont))\r\n" + 
285                 "\r\n" + 
286                 "               $cmd .= \", CAPTIONFONT, \'$this->ol_captionfont\'\";\r\n" + 
287                 "\r\n" + 
288                 "\r\n" + 
289                 "\r\n" + 
290                 "           if (strlen($this->ol_closefont))\r\n" + 
291                 "\r\n" + 
292                 "               $cmd .= \", CLOSEFONT, \'$this->ol_closefont\'\";\r\n" + 
293                 "\r\n" + 
294                 "\r\n" + 
295                 "\r\n" + 
296                 "           if ($this->ol_textsize)\r\n" + 
297                 "\r\n" + 
298                 "               $cmd .= \", TEXTSIZE, $this->ol_textsize\";\r\n" + 
299                 "\r\n" + 
300                 "\r\n" + 
301                 "\r\n" + 
302                 "           if ($this->ol_captionsize)\r\n" + 
303                 "\r\n" + 
304                 "               $cmd .= \", CAPTIONSIZE, $this->ol_captionsize\";\r\n" + 
305                 "\r\n" + 
306                 "\r\n" + 
307                 "\r\n" + 
308                 "           if ($this->ol_closesize)\r\n" + 
309                 "\r\n" + 
310                 "               $cmd .= \", CLOSESIZE, $this->ol_closesize\";\r\n" + 
311                 "\r\n" + 
312                 "\r\n" + 
313                 "\r\n" + 
314                 "           if ($this->ol_width)\r\n" + 
315                 "\r\n" + 
316                 "               $cmd .= \", WIDTH, $this->ol_width\";\r\n" + 
317                 "\r\n" + 
318                 "\r\n" + 
319                 "\r\n" + 
320                 "           if ($this->ol_height)\r\n" + 
321                 "\r\n" + 
322                 "               $cmd .= \", HEIGHT, $this->ol_height\";\r\n" + 
323                 "\r\n" + 
324                 "\r\n" + 
325                 "\r\n" + 
326                 "           if ($this->ol_border >= 0)\r\n" + 
327                 "\r\n" + 
328                 "               $cmd .= \", BORDER, $this->ol_border\";\r\n" + 
329                 "\r\n" + 
330                 "\r\n" + 
331                 "\r\n" + 
332                 "           if ($this->ol_offsetx)\r\n" + 
333                 "\r\n" + 
334                 "               $cmd .= \", OFFSETX, $this->ol_offsetx\";\r\n" + 
335                 "\r\n" + 
336                 "\r\n" + 
337                 "\r\n" + 
338                 "           if ($this->ol_offsety)\r\n" + 
339                 "\r\n" + 
340                 "               $cmd .= \", OFFSETY, $this->ol_offsety\";\r\n" + 
341                 "\r\n" + 
342                 "\r\n" + 
343                 "\r\n" + 
344                 "           if (strlen($this->ol_closetext))\r\n" + 
345                 "\r\n" + 
346                 "               $cmd .= \", CLOSETEXT, \'$this->ol_closetext\'\";\r\n" + 
347                 "\r\n" + 
348                 "\r\n" + 
349                 "\r\n" + 
350                 "           if ($this->ol_noclose)\r\n" + 
351                 "\r\n" + 
352                 "               $cmd .= \", NOCLOSETEXT\";\r\n" + 
353                 "\r\n" + 
354                 "\r\n" + 
355                 "\r\n" + 
356                 "           if ($this->ol_autostatus)\r\n" + 
357                 "\r\n" + 
358                 "               $cmd .= \", AUTOSTATUS\";\r\n" + 
359                 "\r\n" + 
360                 "\r\n" + 
361                 "\r\n" + 
362                 "           if ($this->ol_autostatuscap)\r\n" + 
363                 "\r\n" + 
364                 "               $cmd .= \", AUTOSTATUSCAP\";\r\n" + 
365                 "\r\n" + 
366                 "\r\n" + 
367                 "\r\n" + 
368                 "           if (strlen($this->ol_capicon))\r\n" + 
369                 "\r\n" + 
370                 "               $cmd .= \", CAPICON, \'$this->ol_capicon\'\";\r\n" + 
371                 "\r\n" + 
372                 "\r\n" + 
373                 "\r\n" + 
374                 "           if ($this->ol_snapx)\r\n" + 
375                 "\r\n" + 
376                 "               $cmd .= \", SNAPX, $this->ol_snapx\";\r\n" + 
377                 "\r\n" + 
378                 "\r\n" + 
379                 "\r\n" + 
380                 "           if ($this->ol_snapy)\r\n" + 
381                 "\r\n" + 
382                 "               $cmd .= \", SNAPY, $this->ol_snapy\";\r\n" + 
383                 "\r\n" + 
384                 "\r\n" + 
385                 "\r\n" + 
386                 "           if ($this->ol_fixy)\r\n" + 
387                 "\r\n" + 
388                 "               $cmd .= \", FIXY, $this->ol_fixy\";\r\n" + 
389                 "\r\n" + 
390                 "\r\n" + 
391                 "\r\n" + 
392                 "           if ($this->ol_padxl || $this->ol_padxr)\r\n" + 
393                 "\r\n" + 
394                 "               $cmd .= \", PADX, $this->ol_padxl, $this->ol_padxr\";\r\n" + 
395                 "\r\n" + 
396                 "\r\n" + 
397                 "\r\n" + 
398                 "           if ($this->ol_padyt || $this->ol_padyb)\r\n" + 
399                 "\r\n" + 
400                 "               $cmd .= \", PADY, $this->ol_padyt, $this->ol_padyb\";\r\n" + 
401                 "\r\n" + 
402                 "\r\n" + 
403                 "\r\n" + 
404                 "           if (strlen($this->ol_background))\r\n" + 
405                 "\r\n" + 
406                 "               $cmd .= \", BACKGROUND, \'$this->ol_background\'\";\r\n" + 
407                 "\r\n" + 
408                 "\r\n" + 
409                 "\r\n" + 
410                 "           if ($this->ol_fullhtml)\r\n" + 
411                 "\r\n" + 
412                 "               $cmd .= \", FULLHTML\";\r\n" + 
413                 "\r\n" + 
414                 "\r\n" + 
415                 "\r\n" + 
416                 "           if ($this->ol_timeout >= 0)\r\n" + 
417                 "\r\n" + 
418                 "               $cmd .= \", TIMEOUT, $this->ol_timeout\";\r\n" + 
419                 "\r\n" + 
420                 "\r\n" + 
421                 "\r\n" + 
422                 "           if ($this->ol_delay >= 0)\r\n" + 
423                 "\r\n" + 
424                 "               $cmd .= \", DELAY, $this->ol_delay\";\r\n" + 
425                 "\r\n" + 
426                 "\r\n" + 
427                 "\r\n" + 
428                 "           if ($this->ol_hauto) {\r\n" + 
429                 "\r\n" + 
430                 "               $cmd .= \", HAUTO\";\r\n" + 
431                 "\r\n" + 
432                 "               $this->ol_hauto = false;\r\n" + 
433                 "\r\n" + 
434                 "           }\r\n" + 
435                 "\r\n" + 
436                 "\r\n" + 
437                 "\r\n" + 
438                 "           if ($this->ol_vauto) {\r\n" + 
439                 "\r\n" + 
440                 "               $cmd .= \", VAUTO\";\r\n" + 
441                 "\r\n" + 
442                 "               $this->ol_hauto = false;\r\n" + 
443                 "\r\n" + 
444                 "           }\r\n" + 
445                 "\r\n" + 
446                 "\r\n" + 
447                 "\r\n" + 
448                 "           $output=\" onMouseOver=\\\"return overlib($cmd);\\\" \";\r\n" + 
449                 "\r\n" + 
450                 "           $output.=\" onMouseOut=\\\"nd();\\\" \";\r\n" + 
451                 "\r\n" + 
452                 "\r\n" + 
453                 "\r\n" + 
454                 "           return ($output);\r\n" + 
455                 "\r\n" + 
456                 "         }\r\n" + 
457                 "\r\n" + 
458                 "\r\n" + 
459                 "\r\n" + 
460                 "         function pover ($text, $title = \"\", $status = \"\") \r\n" + 
461                 "\r\n" + 
462                 "         {\r\n" + 
463                 "\r\n" + 
464                 "           echo $this->over($text, $title, $status);\r\n" + 
465                 "\r\n" + 
466                 "         }\r\n" + 
467                 "\r\n" + 
468                 "       }\r\n" + 
469                 "\r\n" + 
470                 "?>\r\n" + 
471                 "\r\n" + 
472                 "\r\n" + 
473                 "\r\n" + 
474                 "\r\n" + 
475                 "\r\n" + 
476                 "");
477   }
478   private void checkPHP(String strEval) {
479     if (Scanner.DEBUG) {
480       System.out.println("\n------------------------------------");
481       System.out.println(strEval);
482     }
483     checkParsePHP(
484         strEval.toCharArray(),
485                 "");
486 //    parser.phpParserTester(strEval, 1);
487   }
488   private void checkHTML(String strEval) {
489     if (Scanner.DEBUG) {
490       System.out.println("\n------------------------------------");
491       System.out.println(strEval);
492     }
493     checkParseHTML(
494         strEval.toCharArray(),
495                 "");
496 //    parser.phpParserTester(strEval, 1);
497   }
498 //  private void checkHTML(String strEval) {
499 //    if (Scanner.DEBUG) {
500 //      System.out.println("\n------------------------------------");
501 //      System.out.println(strEval);
502 //    }
503 //    parser.parse(strEval);
504 //  }
505 //  /**
506 //   * The JUnit setup method
507 //   */
508 //  protected void setUp() {
509 //    parser = new Parser(null);
510 //  }
511 }