package net.sourceforge.phpeclipse.xdebug.php.launching; import java.util.ArrayList; import java.util.List; import junit.framework.TestCase; import net.sourceforge.phpeclipse.xdebug.php.model.XDebugStackFrame; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.ui.PlatformUI; public class PHPSourceLookupParticipantTest extends TestCase { public void testFindSourceElementsObject() throws CoreException { PHPSourceLookupParticipant psp = new PHPSourceLookupParticipant(); Object[] findSourceElements = psp.findSourceElements(new Object()); assertTrue("array should be empty", findSourceElements.length == 0); } public void testFindSourceElementsObject_WithNull() throws CoreException { PHPSourceLookupParticipant psp = new PHPSourceLookupParticipant(); Object[] findSourceElements = psp.findSourceElements(null); assertTrue("array should be empty", findSourceElements.length == 0); } public void testFindSourceElementsObject_WithXdebugStackFrame() throws CoreException { PHPSourceLookupParticipant psp = new PHPSourceLookupParticipant(); XDebugStackFrame frame = new MockXDebugStackFrame(); Object[] findSourceElements = psp.findSourceElements(frame); assertTrue("array should be empty", findSourceElements.length == 0); } class MockXDebugStackFrame extends XDebugStackFrame { public MockXDebugStackFrame() { super(null, 0); } } public void testFindSourceElementsObject_TestPippo() throws CoreException { PHPSourceLookupParticipant psp = new PHPSourceLookupParticipant(); XDebugStackFrame frame = new PippoXDebugStackFrame(); Object[] findSourceElements = psp.findSourceElements(frame); assertEquals(1, findSourceElements.length); assertEquals("pippo", findSourceElements[0]); } class PippoXDebugStackFrame extends XDebugStackFrame { public PippoXDebugStackFrame() { super(null, 0); } public String getType() { return "eval"; } public String getSourceName() { return ""; } } public void testGetSourceName() throws CoreException { PHPSourceLookupParticipant psp = new PHPSourceLookupParticipant(); psp.getSourceName(null); } public void testAddMatching_withNull() { PHPSourceLookupParticipant.addMatching(null, null, null); } public void testAddMatching_updatesList() { // setup List l = new ArrayList(); Object o1 = new Object(); Object o2 = new Object(); Object[] os = new Object[] { o1, o2 }; IPath p = new Path("/some/path"); // test PHPSourceLookupParticipant.addMatching(l, p, os); assertTrue(l.isEmpty()); } }