1
1
package fr .adrienbrault .idea .symfony2plugin .tests .templating ;
2
2
3
- import com .intellij .openapi .application .ApplicationManager ;
4
- import com .intellij .openapi .vfs .VfsUtil ;
5
- import com .intellij .openapi .vfs .VirtualFile ;
6
3
import com .intellij .patterns .PlatformPatterns ;
7
4
import com .jetbrains .twig .TwigFileType ;
8
5
import fr .adrienbrault .idea .symfony2plugin .tests .SymfonyLightCodeInsightFixtureTestCase ;
9
- import org .jetbrains .annotations .NotNull ;
10
-
11
- import java .io .IOException ;
12
6
13
7
/**
14
8
* @author Daniel Espendiller <[email protected] >
@@ -21,6 +15,9 @@ public void setUp() throws Exception {
21
15
myFixture .copyFileToProject ("classes.php" );
22
16
myFixture .copyFileToProject ("TwigTemplateCompletionContributorTest.php" );
23
17
myFixture .copyFileToProject ("routing.xml" );
18
+
19
+ myFixture .copyFileToProject ("ide-twig.json" , "ide-twig.json" );
20
+ myFixture .copyFileToProject ("test.html.twig" , "res/test.html.twig" );
24
21
}
25
22
26
23
public String getTestDataPath () {
@@ -129,23 +126,31 @@ public void testThatIncompleteForStatementIsCompletedWithVariables() {
129
126
);
130
127
}
131
128
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
+ );
150
155
}
151
156
}
0 commit comments