Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide more tests for incomplete completion #1824

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,7 @@
{
"namespaces": [
{
"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 %}