Skip to content

Commit 2584ec7

Browse files
committed
change fixtures building for temporary folder project test cases
1 parent 092e776 commit 2584ec7

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/SymfonyTempCodeInsightFixtureTestCase.java

+14-6
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
import com.intellij.openapi.vfs.VfsUtil;
66
import com.intellij.openapi.vfs.VirtualFile;
77
import com.intellij.testFramework.UsefulTestCase;
8-
import com.intellij.testFramework.fixtures.IdeaProjectTestFixture;
9-
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
8+
import com.intellij.testFramework.fixtures.*;
109
import fr.adrienbrault.idea.symfony2plugin.Settings;
11-
import org.apache.commons.lang.RandomStringUtils;
1210
import org.apache.commons.lang.StringUtils;
1311
import org.jetbrains.annotations.NotNull;
1412
import org.jetbrains.annotations.Nullable;
@@ -19,6 +17,12 @@
1917
import java.util.List;
2018

2119
/**
20+
* Exactly the same as LightCodeInsightFixtureTestCase except uses TempDirTestFixtureImpl instead of LightTempDirTestFixtureImpl.
21+
* This is because the light temp dir stuff fails to work in some cases because it's in-memory file system protocol "temp:" is
22+
* invalid in the eyes of the URL class, which causes URL exceptions. For instance, the Json manifold creates a URL from the resource files.
23+
*
24+
* see https://www.programcreek.com/java-api-examples/?code=manifold-systems/manifold-ij/manifold-ij-master/src/test/java/manifold/ij/SomewhatLightCodeInsightFixtureTestCase.java
25+
*
2226
* @author Daniel Espendiller <[email protected]>
2327
*/
2428
abstract public class SymfonyTempCodeInsightFixtureTestCase extends UsefulTestCase {
@@ -30,9 +34,13 @@ abstract public class SymfonyTempCodeInsightFixtureTestCase extends UsefulTestCa
3034
public void setUp() throws Exception {
3135
super.setUp();
3236

33-
myFixture = IdeaTestFixtureFactory.getFixtureFactory()
34-
.createFixtureBuilder(RandomStringUtils.randomAlphanumeric(20))
35-
.getFixture();
37+
TestFixtureBuilder<IdeaProjectTestFixture> fixtureBuilder = IdeaTestFixtureFactory.getFixtureFactory()
38+
.createLightFixtureBuilder(new DefaultLightProjectDescriptor());
39+
40+
myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(
41+
fixtureBuilder.getFixture(),
42+
IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture()
43+
);
3644

3745
myFixture.setUp();
3846

src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/templating/util/TwigUtilTempTest.java

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package fr.adrienbrault.idea.symfony2plugin.tests.templating.util;
22

33
import com.intellij.openapi.util.Pair;
4-
import com.intellij.openapi.vfs.VfsUtil;
54
import com.intellij.openapi.vfs.VirtualFile;
65
import com.intellij.psi.PsiDirectory;
76
import com.intellij.psi.PsiFile;

0 commit comments

Comments
 (0)