Skip to content

Commit

Permalink
provide more tests for incomplete completion
Browse files Browse the repository at this point in the history
  • Loading branch information
Haehnchen committed Apr 11, 2022
1 parent 06d6bf6 commit d88d4c7
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 24 deletions.
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]>
Expand All @@ -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() {
Expand Down Expand Up @@ -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')"
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"namespaces": [
{
"namespace": "foo",
"path": "res"
},
{
"path": "res"
},
{
"type": "Bundle",
"namespace": "FooBundle",
"path": "res"
}
]
}
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 %}

0 comments on commit d88d4c7

Please sign in to comment.