private void initVersion(@NotNull String version) { myFixture.configureByText(PhpFileType.INSTANCE, "<?php\n" + "namespace Symfony\\Component\\HttpKernel {\n" + " class Kernel {\n" + " const VERSION = '" + version + "';" + " }" + "}" ); } }
/** * @see fr.adrienbrault.idea.symfony2plugin.doctrine.DoctrineUtil#getClassRepositoryPair */ public void testYamlMetadataInvalidByFilename() { myFixture.configureByText("doctrine_foo.yml", "" + "Documents\\Yml\\OrmUserInvalid:\n" + " foo: ~" ); assertIndexNotContains(DoctrineMetadataFileStubIndex.KEY, "Documents\\Yml\\OrmUserInvalid"); }
public void testThatBlockInsideEmbedMustNotProvideBlockLineMarkerForFileScope() { if(System.getenv("PHPSTORM_ENV") != null) return; myFixture.addFileToProject("app/Resources/views/block.html.twig", "{% block foo %}{% endblock %}"); PsiFile psiFile = myFixture.configureByText(TwigFileType.INSTANCE, "" + "{% extends 'block.html.twig' %}\n" + "{% embed 'foo.html.twig' %}\n" + " {% block foo %}{% endblock %}\n" + "{% endembed %}" ); assertLineMarkerIsEmpty(psiFile); }
public void testGetBlockLookupElements() { PsiFile psiFile = myFixture.configureByText("foo.html.twig", "{% block name %}{% endblock %}"); PsiFile psiFile2 = myFixture.configureByText("foo_2.html.twig", "{% block foobar %}{% endblock %}"); myFixture.configureByText("foo_3.html.twig", "{% block foobar_2 %}{% endblock %}"); Collection<LookupElement> lookupElements = TwigUtil.getBlockLookupElements(getProject(), Arrays.asList(psiFile.getVirtualFile(), psiFile2.getVirtualFile())); assertSize(2, lookupElements); assertNotNull(lookupElements.stream().filter(lookupElement -> "name".equals(lookupElement.getLookupString())).findFirst().orElse(null)); assertNotNull(lookupElements.stream().filter(lookupElement -> "foobar".equals(lookupElement.getLookupString())).findFirst().orElse(null)); }
public void setUp() throws Exception { super.setUp(); myFixture.copyFileToProject("appDevDebugProjectContainer.xml"); myFixture.configureByText("classes.php", "<?php\n" + "namespace Foo\\Name;\n" + "class FooClass {" + " public function foo() " + "}" ); }
public void assertCompletionNotContains(String filename, String configureByText, String... lookupStrings) { myFixture.configureByText(filename, configureByText); myFixture.completeBasic(); assertFalse(myFixture.getLookupElementStrings().containsAll(Arrays.asList(lookupStrings))); }
public void assertCompletionContains(String filename, String configureByText, String... lookupStrings) { myFixture.configureByText(filename, configureByText); myFixture.completeBasic(); completionContainsAssert(lookupStrings); }
public void assertCompletionResultEquals(LanguageFileType languageFileType, String complete, String result) { myFixture.configureByText(languageFileType, complete); myFixture.completeBasic(); myFixture.checkResult(result); }
public void testThatRouteLineMarkerForControllerIsGiven() { assertLineMarker( myFixture.configureByText("foo.xml", "<routes><route controller=\"Foo\\Bar\"/></routes>"), new LineMarker.ToolTipEqualsAssert("Navigate to action") ); assertLineMarker( myFixture.configureByText("foo.xml", "<routes><route><default key=\"_controller\">Foo\\Bar</default></route></routes>"), new LineMarker.ToolTipEqualsAssert("Navigate to action") ); } }
public void assertReferenceMatch(@NotNull FileType fileType, @NotNull String contents, @NotNull ElementPattern<?> pattern) { myFixture.configureByText(fileType, contents); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); if(psiElement == null) { fail("Fail to find element in caret"); } assertReferences(pattern, psiElement); }
public void testVersionSuffixStrip() { myFixture.configureByText(PhpFileType.INSTANCE, "<?php\n" + "namespace Symfony\\Component\\HttpKernel {\n" + " class Kernel {\n" + " const VERSION = '3.2.0-RC1';" + " }" + "}" ); assertTrue(SymfonyUtil.isVersionGreaterThen(getProject(), "3.1.0")); }
public void testVersionSuffixStrip3() { myFixture.configureByText(PhpFileType.INSTANCE, "<?php\n" + "namespace Symfony\\Component\\HttpKernel {\n" + " class Kernel {\n" + " const VERSION = '3.2.0-RC_111';" + " }" + "}" ); assertTrue(SymfonyUtil.isVersionGreaterThen(getProject(), "3.1.0")); }
public void setUp() throws Exception { super.setUp(); myFixture.copyFileToProject("BundleScopeLineMarkerProvider.php"); myFixture.copyFileToProject("XmlLineMarkerProvider.php"); myFixture.configureByText( XmlFileType.INSTANCE, "<routes><import resource=\"@FooBundle/foo.xml\" /></routes>" ); }
@NotNull private PsiElement assertGetPhpReference(LanguageFileType languageFileType, String configureByText) { myFixture.configureByText(languageFileType, configureByText); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); psiElement = PsiTreeUtil.getParentOfType(psiElement, PhpReference.class); if (psiElement == null) { fail("Element is not PhpReference."); } return psiElement; }
public void testActionAvailableForFileScope() { myFixture.configureByText(PhpFileType.INSTANCE, "" + "<?php\n" + "class Foo implements \\Symfony\\Component\\Form\\FormTypeInterface\n" + "{" + " \n private $foo = 'te<caret>st';\n" + "} " ); assertTrue(myFixture.testAction(new FormTypeConstantMigrationAction()).isEnabledAndVisible()); } }
public void assertNavigationContains(LanguageFileType languageFileType, String configureByText, String targetShortcut) { myFixture.configureByText(languageFileType, configureByText); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); assertNavigationContains(psiElement, targetShortcut); }
public void testActionAvailableForFileScope() { myFixture.configureByText("foo.html.twig", "{{ foo }}"); assertTrue(myFixture.testAction(new TwigTranslationGeneratorAction()).isEnabledAndVisible()); } }
public void testTemplateNameExtractionForFunctionForFunctions() { myFixture.configureByText(PhpFileType.INSTANCE, "<?php foo('foo.html.twig', array_merge(['<caret>' => 'foo']));"); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); assertContainsElements(RenderParameterGotoCompletionRegistrar.getTemplatesForScope(psiElement), "foo.html.twig"); }
public void testTemplateNameExtractionForFunction() { myFixture.configureByText(PhpFileType.INSTANCE, "<?php foo('foo.html.twig', ['<caret>']);"); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); assertContainsElements(RenderParameterGotoCompletionRegistrar.getTemplatesForScope(psiElement), "foo.html.twig"); myFixture.configureByText(PhpFileType.INSTANCE, "<?php foo('foo.html.twig', ['<caret>' => 'foo']);"); psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); assertContainsElements(RenderParameterGotoCompletionRegistrar.getTemplatesForScope(psiElement), "foo.html.twig"); }
/** * @see XmlHelper#getArgumentIndex */ public void testGetArgumentIndex() { myFixture.configureByText(XmlFileType.INSTANCE, "" + "<service class=\"Foo\\Bar\">\n" + " <argum<caret>ent key=\"$foobar1\" />\n" + "</service>" ); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); assertEquals(1, XmlHelper.getArgumentIndex((XmlTag) psiElement.getParent())); }