for (String testsDirectory : TESTS.get(phpVersion)) {
for (final String fileName : getPDTTFiles(testsDirectory)) {
try {
final PdttFile pdttFile = new PdttFile(fileName);
filesMap.put(pdttFile, null);
phpVerSuite.addTest(new FormatterTests(phpVersion
.getAlias() + " - /" + fileName) {
protected void setUp() throws Exception {
PHPCoreTests.setProjectPhpVersion(project,
phpVersion);
}
protected void runTest() throws Throwable {
IFile file = filesMap.get(pdttFile);
ISourceModule modelElement = (ISourceModule) DLTKCore
.create(file);
if (ScriptModelUtil.isPrimary(modelElement))
modelElement.becomeWorkingCopy(
new IProblemRequestor() {
public void acceptProblem(
IProblem problem) {
// TODO Auto-generated
// method stub
}
public void beginReporting() {
// TODO Auto-generated
// method stub
}
public void endReporting() {
// TODO Auto-generated
// method stub
}
public boolean isActive() {
// TODO Auto-generated
// method stub
return false;
}
}, null);
IStructuredModel modelForEdit = StructuredModelManager
.getModelManager()
.getModelForEdit(file);
try {
IDocument document = modelForEdit
.getStructuredDocument();
String beforeFormat = document.get();
PhpFormatProcessorImpl formatter = new PhpFormatProcessorImpl();
formatter.formatDocument(document, 0,
document.getLength());
assertContents(pdttFile.getExpected(),
document.get());
// change the document text as was before
// the formatting
document.set(beforeFormat);