diff --git a/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/config/yaml/YamlLanguageInjectorTest.java b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/config/yaml/YamlLanguageInjectorTest.java new file mode 100644 index 000000000..36642bbaf --- /dev/null +++ b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/config/yaml/YamlLanguageInjectorTest.java @@ -0,0 +1,63 @@ +package fr.adrienbrault.idea.symfony2plugin.tests.config.yaml; + +import com.intellij.testFramework.fixtures.InjectionTestFixture; +import fr.adrienbrault.idea.symfony2plugin.tests.SymfonyLightCodeInsightFixtureTestCase; +import org.jetbrains.annotations.NotNull; + +public class YamlLanguageInjectorTest extends SymfonyLightCodeInsightFixtureTestCase { + + private InjectionTestFixture injectionTestFixture; + + @Override + public void setUp() throws Exception { + super.setUp(); + + injectionTestFixture = new InjectionTestFixture(myFixture); + } + + public void testLanguageInjections() { + assertExpressionLanguageIsInjectedAtCaret( + "services.yaml", + "services:\n" + + " App\\Service\\ExampleService:\n" + + " arguments:\n" + + " $example: '@=service('\n" + ); + + assertExpressionLanguageIsInjectedAtCaret( + "services.yaml", + "services:\n" + + " App\\Service\\ExampleService:\n" + + " calls:\n" + + " - example: ['@=service(']\n" + ); + + assertExpressionLanguageIsInjectedAtCaret( + "services.yaml", + "services:\n" + + " App\\Service\\ExampleService:\n" + + " properties:\n" + + " example: '@=service(']\n" + ); + + assertExpressionLanguageIsInjectedAtCaret( + "services.yaml", + "services:\n" + + " App\\Service\\ExampleService:\n" + + " configurator: ['@=service(', 'configure']\n" + ); + + assertExpressionLanguageIsInjectedAtCaret( + "routing.yaml", + "app.contact:\n" + + " path: /contact\n" + + " controller: 'App\\Controller\\DefaultController::contact'\n" + + " condition: 'context.getMethod() in '\n" + ); + } + + private void assertExpressionLanguageIsInjectedAtCaret(@NotNull String fileName, @NotNull String text) { + myFixture.configureByText(fileName, text); + injectionTestFixture.assertInjectedLangAtCaret("Symfony Expression Language"); + } +}