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+ }
0 commit comments