|
| 1 | +package fr.adrienbrault.idea.symfony2plugin.tests.config.yaml; |
| 2 | + |
| 3 | +import com.intellij.testFramework.fixtures.InjectionTestFixture; |
| 4 | +import fr.adrienbrault.idea.symfony2plugin.tests.SymfonyLightCodeInsightFixtureTestCase; |
| 5 | +import org.jetbrains.annotations.NotNull; |
| 6 | + |
| 7 | +public class YamlLanguageInjectorTest extends SymfonyLightCodeInsightFixtureTestCase { |
| 8 | + |
| 9 | + private InjectionTestFixture injectionTestFixture; |
| 10 | + |
| 11 | + @Override |
| 12 | + public void setUp() throws Exception { |
| 13 | + super.setUp(); |
| 14 | + |
| 15 | + injectionTestFixture = new InjectionTestFixture(myFixture); |
| 16 | + } |
| 17 | + |
| 18 | + public void testLanguageInjections() { |
| 19 | + assertExpressionLanguageIsInjectedAtCaret( |
| 20 | + "services.yaml", |
| 21 | + "services:\n" + |
| 22 | + " App\\Service\\ExampleService:\n" + |
| 23 | + " arguments:\n" + |
| 24 | + " $example: '@=service(<caret>'\n" |
| 25 | + ); |
| 26 | + |
| 27 | + assertExpressionLanguageIsInjectedAtCaret( |
| 28 | + "services.yaml", |
| 29 | + "services:\n" + |
| 30 | + " App\\Service\\ExampleService:\n" + |
| 31 | + " calls:\n" + |
| 32 | + " - example: ['@=service(<caret>']\n" |
| 33 | + ); |
| 34 | + |
| 35 | + assertExpressionLanguageIsInjectedAtCaret( |
| 36 | + "services.yaml", |
| 37 | + "services:\n" + |
| 38 | + " App\\Service\\ExampleService:\n" + |
| 39 | + " properties:\n" + |
| 40 | + " example: '@=service(<caret>']\n" |
| 41 | + ); |
| 42 | + |
| 43 | + assertExpressionLanguageIsInjectedAtCaret( |
| 44 | + "services.yaml", |
| 45 | + "services:\n" + |
| 46 | + " App\\Service\\ExampleService:\n" + |
| 47 | + " configurator: ['@=service(<caret>', 'configure']\n" |
| 48 | + ); |
| 49 | + |
| 50 | + assertExpressionLanguageIsInjectedAtCaret( |
| 51 | + "routing.yaml", |
| 52 | + "app.contact:\n" + |
| 53 | + " path: /contact\n" + |
| 54 | + " controller: 'App\\Controller\\DefaultController::contact'\n" + |
| 55 | + " condition: 'context.getMethod() in <caret>'\n" |
| 56 | + ); |
| 57 | + } |
| 58 | + |
| 59 | + private void assertExpressionLanguageIsInjectedAtCaret(@NotNull String fileName, @NotNull String text) { |
| 60 | + myFixture.configureByText(fileName, text); |
| 61 | + injectionTestFixture.assertInjectedLangAtCaret("Symfony Expression Language"); |
| 62 | + } |
| 63 | +} |
0 commit comments