Skip to content

Commit d9ad1e4

Browse files
committed
Fixed #1667: Rename refactoring ignores constants inside yaml files (tests)
1 parent 8a6621c commit d9ad1e4

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package fr.adrienbrault.idea.symfony2plugin.tests.config.yaml;
2+
3+
import com.intellij.patterns.PlatformPatterns;
4+
import com.jetbrains.php.lang.psi.elements.Field;
5+
import com.jetbrains.php.lang.psi.elements.PhpDefine;
6+
import fr.adrienbrault.idea.symfony2plugin.tests.SymfonyLightCodeInsightFixtureTestCase;
7+
import org.jetbrains.yaml.YAMLFileType;
8+
9+
public class YamlReferenceContributorTest extends SymfonyLightCodeInsightFixtureTestCase {
10+
11+
public void setUp() throws Exception {
12+
super.setUp();
13+
myFixture.copyFileToProject("YamlReferenceContributor.php");
14+
}
15+
16+
public String getTestDataPath() {
17+
return "src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/config/yaml/fixtures";
18+
}
19+
20+
public void testConstantProvidesReferences() {
21+
assertReferenceMatchOnParent(
22+
YAMLFileType.YML,
23+
"services:\n" +
24+
" app.service.example:\n" +
25+
" arguments:\n" +
26+
" - !php/const CONST_<caret>FOO\n",
27+
PlatformPatterns.psiElement(PhpDefine.class).withName("CONST_FOO")
28+
);
29+
30+
assertReferenceMatchOnParent(
31+
YAMLFileType.YML,
32+
"services:\n" +
33+
" app.service.example:\n" +
34+
" arguments:\n" +
35+
" - !php/const Foo\\Bar::F<caret>OO\n",
36+
PlatformPatterns.psiElement(Field.class).withName("FOO")
37+
);
38+
}
39+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace
4+
{
5+
define('CONST_FOO', 'CONST_FOO');
6+
}
7+
8+
namespace Foo
9+
{
10+
class Bar
11+
{
12+
const FOO = 'foo';
13+
}
14+
}

0 commit comments

Comments
 (0)