Skip to content

Commit d88d4c7

Browse files
committed
provide more tests for incomplete completion
1 parent 06d6bf6 commit d88d4c7

File tree

3 files changed

+50
-24
lines changed

3 files changed

+50
-24
lines changed

src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/templating/TwigTemplateCompletionContributorTest.java

+29-24
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
package fr.adrienbrault.idea.symfony2plugin.tests.templating;
22

3-
import com.intellij.openapi.application.ApplicationManager;
4-
import com.intellij.openapi.vfs.VfsUtil;
5-
import com.intellij.openapi.vfs.VirtualFile;
63
import com.intellij.patterns.PlatformPatterns;
74
import com.jetbrains.twig.TwigFileType;
85
import fr.adrienbrault.idea.symfony2plugin.tests.SymfonyLightCodeInsightFixtureTestCase;
9-
import org.jetbrains.annotations.NotNull;
10-
11-
import java.io.IOException;
126

137
/**
148
* @author Daniel Espendiller <[email protected]>
@@ -21,6 +15,9 @@ public void setUp() throws Exception {
2115
myFixture.copyFileToProject("classes.php");
2216
myFixture.copyFileToProject("TwigTemplateCompletionContributorTest.php");
2317
myFixture.copyFileToProject("routing.xml");
18+
19+
myFixture.copyFileToProject("ide-twig.json", "ide-twig.json");
20+
myFixture.copyFileToProject("test.html.twig", "res/test.html.twig");
2421
}
2522

2623
public String getTestDataPath() {
@@ -129,23 +126,31 @@ public void testThatIncompleteForStatementIsCompletedWithVariables() {
129126
);
130127
}
131128

132-
private void createWorkaroundFile(@NotNull String file, @NotNull String content) {
133-
134-
try {
135-
createDummyFiles(file);
136-
} catch (Exception e) {
137-
e.printStackTrace();
138-
}
139-
140-
// build pseudo file with block
141-
final VirtualFile relativeFile = VfsUtil.findRelativeFile(getProject().getBaseDir(), file.split("/"));
142-
ApplicationManager.getApplication().runWriteAction(() -> {
143-
try {
144-
relativeFile.setBinaryContent(content.getBytes());
145-
} catch (IOException e2) {
146-
e2.printStackTrace();
147-
}
148-
relativeFile.refresh(false, false);
149-
});
129+
public void testThatIncompleteExtendsStatementIsCompleted() {
130+
assertCompletionContains(TwigFileType.INSTANCE, "" +
131+
"{% ext<caret> %}\n",
132+
"extends 'test.html.twig'"
133+
);
134+
}
135+
136+
public void testThatIncompleteIncludeStatementIsCompleted() {
137+
assertCompletionContains(TwigFileType.INSTANCE, "" +
138+
"{% inc<caret> %}\n",
139+
"include 'test.html.twig'"
140+
);
141+
}
142+
143+
public void testThatIncompleteEmbedStatementIsCompleted() {
144+
assertCompletionContains(TwigFileType.INSTANCE, "" +
145+
"{% emb<caret> %}\n",
146+
"embed 'test.html.twig'"
147+
);
148+
}
149+
150+
public void testThatIncompleteIncludePrintIsCompleted() {
151+
assertCompletionContains(TwigFileType.INSTANCE, "" +
152+
"{{ in<caret>c }}\n",
153+
"include('test.html.twig')"
154+
);
150155
}
151156
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"namespaces": [
3+
{
4+
"namespace": "foo",
5+
"path": "res"
6+
},
7+
{
8+
"path": "res"
9+
},
10+
{
11+
"type": "Bundle",
12+
"namespace": "FooBundle",
13+
"path": "res"
14+
}
15+
]
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% include 'test.html.twig' %}
2+
3+
{% embed 'test.html.twig' %}
4+
5+
{% block test %}{% endblock %}

0 commit comments

Comments
 (0)