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