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