Skip to content

Commit 4f19273

Browse files
committed
Merge pull request #37 from agallou/save_before_run
save test and tested file before run
2 parents a879861 + f415407 commit 4f19273

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Features
44

55
* [#30](https://github.com/agallou/phpstorm-plugin/pull/30) Easily identify test files via a custom icon ([@agallou])
6+
* [#37](https://github.com/agallou/phpstorm-plugin/pull/37) Save test and tested file before run ([@agallou])
67

78
## Documentation
89

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ You can run the tests from both the test file or the tested classe's file :
5353

5454
![Demo](doc/run_from_tested_class.png)
5555

56+
Your test file and tested file will automatically be save before running the test.
5657

5758
### Easily identify test files by a custom icon
5859

src/pl/projectspace/idea/plugins/php/atoum/actions/AtoumRunTests.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import com.intellij.openapi.actionSystem.AnAction;
88
import com.intellij.openapi.actionSystem.AnActionEvent;
99
import com.intellij.openapi.actionSystem.PlatformDataKeys;
10+
import com.intellij.openapi.editor.Document;
11+
import com.intellij.openapi.fileEditor.FileDocumentManager;
1012
import com.intellij.openapi.project.Project;
1113
import com.intellij.openapi.vfs.VirtualFile;
1214
import com.intellij.openapi.wm.ToolWindow;
@@ -46,6 +48,14 @@ public void update(AnActionEvent event) {
4648
event.getPresentation().setEnabled(true);
4749
}
4850

51+
protected void saveFiles(PhpClass currentTestClass, Project project) {
52+
Document documentTestClass = FileDocumentManager.getInstance().getDocument(currentTestClass.getContainingFile().getVirtualFile());
53+
Document documentTestedClass = FileDocumentManager.getInstance().getDocument(Utils.locateTestedClass(project, currentTestClass).getContainingFile().getVirtualFile());
54+
FileDocumentManager.getInstance().saveDocument(documentTestClass);
55+
FileDocumentManager.getInstance().saveDocument(documentTestedClass);
56+
57+
}
58+
4959
public void actionPerformed(final AnActionEvent e) {
5060
PhpClass currentTestClass = getCurrentTestClass(e);
5161
if (currentTestClass == null) {
@@ -57,6 +67,8 @@ public void actionPerformed(final AnActionEvent e) {
5767
ToolWindow toolWindow = getToolWindow(project);
5868
ConsoleView console = getConsole(toolWindow, project);
5969

70+
saveFiles(currentTestClass, project);
71+
6072
String output = runTest(currentTestClass, project);
6173

6274
toolWindow.setIcon(Icons.ATOUM);

0 commit comments

Comments
 (0)