for (String testsDirectory : TESTS.get(phpVersion)) {
for (final String fileName : getPDTTFiles(testsDirectory)) {
try {
final CodeAssistPdttFile pdttFile = new CodeAssistPdttFile(
fileName);
phpVerSuite.addTest(new SelectionEngineTests(phpVersion
.getAlias() + " - /" + fileName) {
protected void setUp() throws Exception {
PHPCoreTests.setProjectPhpVersion(project,
phpVersion);
}
protected void tearDown() throws Exception {
if (testFile != null) {
testFile.delete(true, null);
testFile = null;
}
}
protected void runTest() throws Throwable {
IModelElement[] elements = getSelection(pdttFile
.getFile());
ExpectedProposal[] expectedProposals = pdttFile
.getExpectedProposals();
boolean proposalsEqual = true;
if (elements.length == expectedProposals.length) {
for (ExpectedProposal expectedProposal : pdttFile
.getExpectedProposals()) {
boolean found = false;
for (IModelElement modelElement : elements) {
if (modelElement.getElementType() == expectedProposal.type
&& modelElement
.getElementName()
.equalsIgnoreCase(
expectedProposal.name)) {
found = true;
break;
}
}
if (!found) {
proposalsEqual = false;
break;
}
}
} else {
proposalsEqual = false;
}
if (!proposalsEqual) {
StringBuilder errorBuf = new StringBuilder();
errorBuf.append("\nEXPECTED ELEMENTS LIST:\n-----------------------------\n");
errorBuf.append(pdttFile.getExpected());
errorBuf.append("\nACTUAL ELEMENTS LIST:\n-----------------------------\n");
for (IModelElement modelElement : elements) {
switch (modelElement.getElementType()) {
case IModelElement.FIELD:
errorBuf.append("field");