Skip to content

Commit 777cd4c

Browse files
committed
Add test for ParameterLanguageInjector
1 parent 33d4c93 commit 777cd4c

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package fr.adrienbrault.idea.symfony2plugin.tests.lang;
2+
3+
import com.intellij.openapi.fileTypes.LanguageFileType;
4+
import com.intellij.testFramework.fixtures.InjectionTestFixture;
5+
import com.jetbrains.php.lang.PhpFileType;
6+
import fr.adrienbrault.idea.symfony2plugin.tests.SymfonyLightCodeInsightFixtureTestCase;
7+
8+
public class ParameterLanguageInjectorTest extends SymfonyLightCodeInsightFixtureTestCase {
9+
10+
private InjectionTestFixture injectionTestFixture;
11+
12+
@Override
13+
public void setUp() throws Exception {
14+
super.setUp();
15+
injectionTestFixture = new InjectionTestFixture(myFixture);
16+
myFixture.copyFileToProject("classes.php");
17+
18+
}
19+
20+
public String getTestDataPath() {
21+
return "src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/lang/fixtures";
22+
}
23+
24+
public void testCssLanguageInjections() {
25+
String base = "$c = new \\Symfony\\Component\\DomCrawler\\Crawler();\n";
26+
assertInjectedLangAtCaret(PhpFileType.INSTANCE, base + "$c->filter('html > bo<caret>dy');", "CSS");
27+
assertInjectedLangAtCaret(PhpFileType.INSTANCE, base + "$c->filter('<caret>');", "CSS");
28+
assertInjectedLangAtCaret(PhpFileType.INSTANCE, base + "$c->children('html > bo<caret>dy');", "CSS");
29+
assertInjectedLangAtCaret(PhpFileType.INSTANCE, base + "$c->children('<caret>');", "CSS");
30+
}
31+
32+
public void testXPathLanguageInjections() {
33+
String base = "$c = new \\Symfony\\Component\\DomCrawler\\Crawler();\n";
34+
assertInjectedLangAtCaret(PhpFileType.INSTANCE, base + "$c->filterXPath('<caret>');", "XPath");
35+
assertInjectedLangAtCaret(PhpFileType.INSTANCE, base + "$c->evaluate('<caret>');", "XPath");
36+
37+
}
38+
39+
private void assertInjectedLangAtCaret(LanguageFileType fileType, String configureByText, String lang) {
40+
myFixture.configureByText(fileType, configureByText);
41+
injectionTestFixture.assertInjectedLangAtCaret(lang);
42+
}
43+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Symfony\Component\DomCrawler {
4+
class Crawler
5+
{
6+
public function filter($str)
7+
{
8+
}
9+
public function children($str)
10+
{
11+
}
12+
public function filterXPath($str)
13+
{
14+
}
15+
public function evaluate($str)
16+
{
17+
}
18+
}
19+
}
20+
21+
namespace Symfony\Component\CssSelector {
22+
class CssSelectorConverter
23+
{
24+
public function toXPath($str)
25+
{
26+
}
27+
}
28+
}
29+

0 commit comments

Comments
 (0)