-
-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provide more tests for incomplete completion
- Loading branch information
Showing
3 changed files
with
41 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
package fr.adrienbrault.idea.symfony2plugin.tests.templating; | ||
|
||
import com.intellij.openapi.application.ApplicationManager; | ||
import com.intellij.openapi.vfs.VfsUtil; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
import com.intellij.patterns.PlatformPatterns; | ||
import com.jetbrains.twig.TwigFileType; | ||
import fr.adrienbrault.idea.symfony2plugin.tests.SymfonyLightCodeInsightFixtureTestCase; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* @author Daniel Espendiller <[email protected]> | ||
|
@@ -21,6 +15,9 @@ public void setUp() throws Exception { | |
myFixture.copyFileToProject("classes.php"); | ||
myFixture.copyFileToProject("TwigTemplateCompletionContributorTest.php"); | ||
myFixture.copyFileToProject("routing.xml"); | ||
|
||
myFixture.copyFileToProject("ide-twig.json", "ide-twig.json"); | ||
myFixture.copyFileToProject("test.html.twig", "res/test.html.twig"); | ||
} | ||
|
||
public String getTestDataPath() { | ||
|
@@ -129,23 +126,31 @@ public void testThatIncompleteForStatementIsCompletedWithVariables() { | |
); | ||
} | ||
|
||
private void createWorkaroundFile(@NotNull String file, @NotNull String content) { | ||
|
||
try { | ||
createDummyFiles(file); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
// build pseudo file with block | ||
final VirtualFile relativeFile = VfsUtil.findRelativeFile(getProject().getBaseDir(), file.split("/")); | ||
ApplicationManager.getApplication().runWriteAction(() -> { | ||
try { | ||
relativeFile.setBinaryContent(content.getBytes()); | ||
} catch (IOException e2) { | ||
e2.printStackTrace(); | ||
} | ||
relativeFile.refresh(false, false); | ||
}); | ||
public void testThatIncompleteExtendsStatementIsCompleted() { | ||
assertCompletionContains(TwigFileType.INSTANCE, "" + | ||
"{% ext<caret> %}\n", | ||
"extends 'test.html.twig'" | ||
); | ||
} | ||
|
||
public void testThatIncompleteIncludeStatementIsCompleted() { | ||
assertCompletionContains(TwigFileType.INSTANCE, "" + | ||
"{% inc<caret> %}\n", | ||
"include 'test.html.twig'" | ||
); | ||
} | ||
|
||
public void testThatIncompleteEmbedStatementIsCompleted() { | ||
assertCompletionContains(TwigFileType.INSTANCE, "" + | ||
"{% emb<caret> %}\n", | ||
"embed 'test.html.twig'" | ||
); | ||
} | ||
|
||
public void testThatIncompleteIncludePrintIsCompleted() { | ||
assertCompletionContains(TwigFileType.INSTANCE, "" + | ||
"{{ in<caret>c }}\n", | ||
"include('test.html.twig')" | ||
); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/templating/fixtures/ide-twig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"namespaces": [ | ||
{ | ||
"path": "res" | ||
} | ||
] | ||
} |
5 changes: 5 additions & 0 deletions
5
src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/templating/fixtures/test.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% include 'test.html.twig' %} | ||
|
||
{% embed 'test.html.twig' %} | ||
|
||
{% block test %}{% endblock %} |