11package 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 ;
63import com .intellij .patterns .PlatformPatterns ;
74import com .jetbrains .twig .TwigFileType ;
85import 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}
0 commit comments