1) Fixed issue #714: PHP Parser bug with $this->oR.
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.test / src / net / sourceforge / phpeclipse / xdebug / php / launching / PHPSourceLookupParticipantTest.java
1 package net.sourceforge.phpeclipse.xdebug.php.launching;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import junit.framework.TestCase;
7 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugStackFrame;
8
9 import org.eclipse.core.resources.IFile;
10 import org.eclipse.core.runtime.CoreException;
11 import org.eclipse.core.runtime.IPath;
12 import org.eclipse.core.runtime.Path;
13 import org.eclipse.core.runtime.Platform;
14 import org.eclipse.ui.PlatformUI;
15
16 public class PHPSourceLookupParticipantTest extends TestCase {
17
18         public void testFindSourceElementsObject() throws CoreException {
19                 PHPSourceLookupParticipant psp = new PHPSourceLookupParticipant();
20                 Object[] findSourceElements = psp.findSourceElements(new Object());
21                 assertTrue("array should be empty", findSourceElements.length == 0);
22         }
23
24         public void testFindSourceElementsObject_WithNull() throws CoreException {
25                 PHPSourceLookupParticipant psp = new PHPSourceLookupParticipant();
26                 Object[] findSourceElements = psp.findSourceElements(null);
27                 assertTrue("array should be empty", findSourceElements.length == 0);
28         }
29
30         public void testFindSourceElementsObject_WithXdebugStackFrame()
31                         throws CoreException {
32                 PHPSourceLookupParticipant psp = new PHPSourceLookupParticipant();
33                 XDebugStackFrame frame = new MockXDebugStackFrame();
34                 Object[] findSourceElements = psp.findSourceElements(frame);
35                 assertTrue("array should be empty", findSourceElements.length == 0);
36         }
37
38         class MockXDebugStackFrame extends XDebugStackFrame {
39                 public MockXDebugStackFrame() {
40                         super(null, 0);
41                 }
42         }
43
44         public void testFindSourceElementsObject_TestPippo() throws CoreException {
45                 PHPSourceLookupParticipant psp = new PHPSourceLookupParticipant();
46                 XDebugStackFrame frame = new PippoXDebugStackFrame();
47                 Object[] findSourceElements = psp.findSourceElements(frame);
48                 assertEquals(1, findSourceElements.length);
49                 assertEquals("pippo", findSourceElements[0]);
50         }
51
52         class PippoXDebugStackFrame extends XDebugStackFrame {
53                 public PippoXDebugStackFrame() {
54                         super(null, 0);
55                 }
56
57                 public String getType() {
58                         return "eval";
59                 }
60
61                 public String getSourceName() {
62                         return "";
63                 }
64         }
65
66         public void testGetSourceName() throws CoreException {
67                 PHPSourceLookupParticipant psp = new PHPSourceLookupParticipant();
68                 psp.getSourceName(null);
69         }
70
71         public void testAddMatching_withNull() {
72                 PHPSourceLookupParticipant.addMatching(null, null, null);
73         }
74
75         public void testAddMatching_updatesList() {
76                 // setup
77                 List l = new ArrayList();
78
79                 Object o1 = new Object();
80                 Object o2 = new Object();
81                 Object[] os = new Object[] { o1, o2 };
82
83                 IPath p = new Path("/some/path");
84
85                 // test
86                 PHPSourceLookupParticipant.addMatching(l, p, os);
87                 assertTrue(l.isEmpty());
88         }
89         
90
91 }