diff --git a/src/test/kotlin/com/vk/kphpstorm/testing/infrastructure/InspectionTestBase.kt b/src/test/kotlin/com/vk/kphpstorm/testing/infrastructure/InspectionTestBase.kt index f69e222..8e8bb35 100644 --- a/src/test/kotlin/com/vk/kphpstorm/testing/infrastructure/InspectionTestBase.kt +++ b/src/test/kotlin/com/vk/kphpstorm/testing/infrastructure/InspectionTestBase.kt @@ -1,21 +1,11 @@ package com.vk.kphpstorm.testing.infrastructure -import com.intellij.testFramework.fixtures.BasePlatformTestCase -import com.jetbrains.php.config.PhpLanguageLevel -import com.jetbrains.php.config.PhpProjectConfigurationFacade import com.jetbrains.php.lang.inspections.PhpInspection import com.vk.kphpstorm.configuration.KphpStormConfiguration import com.vk.kphpstorm.configuration.setupKphpStormPluginForProject import java.io.File - -abstract class InspectionTestBase( - private val inspectionToEnable: PhpInspection? = null, -) : BasePlatformTestCase() { - - open val languageLevel: PhpLanguageLevel = PhpLanguageLevel.PHP740 - - override fun getTestDataPath() = "src/test/fixtures" +abstract class InspectionTestBase(private val inspectionToEnable: PhpInspection? = null) : KphpStormTestBase() { override fun setUp() { super.setUp() @@ -25,17 +15,11 @@ abstract class InspectionTestBase( } } - private fun setupLanguageLevel() { - val projectConfigurationFacade = PhpProjectConfigurationFacade.getInstance(project) - projectConfigurationFacade.languageLevel = languageLevel - } - /** * Run inspection on file.fixture.php and check that all and match * If file.qf.php exists, apply quickfixes and compare result to file.qf.php */ protected fun runFixture(fixtureFile: String) { - setupLanguageLevel() setupKphpStormPluginForProject(project) // Highlighting test diff --git a/src/test/kotlin/com/vk/kphpstorm/testing/infrastructure/IntentionTestBase.kt b/src/test/kotlin/com/vk/kphpstorm/testing/infrastructure/IntentionTestBase.kt index cc39a30..504d9bc 100644 --- a/src/test/kotlin/com/vk/kphpstorm/testing/infrastructure/IntentionTestBase.kt +++ b/src/test/kotlin/com/vk/kphpstorm/testing/infrastructure/IntentionTestBase.kt @@ -1,32 +1,15 @@ package com.vk.kphpstorm.testing.infrastructure import com.intellij.codeInsight.intention.IntentionAction -import com.intellij.testFramework.fixtures.BasePlatformTestCase -import com.jetbrains.php.config.PhpLanguageLevel -import com.jetbrains.php.config.PhpProjectConfigurationFacade import com.vk.kphpstorm.configuration.KphpStormConfiguration - -abstract class IntentionTestBase( - private val intentionToExecute: IntentionAction -) : BasePlatformTestCase() { - - open val languageLevel: PhpLanguageLevel = PhpLanguageLevel.PHP740 - - override fun getTestDataPath() = "src/test/fixtures" - - private fun setupLanguageLevel() { - val projectConfigurationFacade = PhpProjectConfigurationFacade.getInstance(project) - projectConfigurationFacade.languageLevel = languageLevel - } +abstract class IntentionTestBase(private val intentionToExecute: IntentionAction) : KphpStormTestBase() { /** * Run intention on file.fixture.php at place marked * file.qf.php must exist, the result of applying intention is compared to its contents */ protected fun runIntention(fixtureFile: String) { - setupLanguageLevel() - KphpStormConfiguration.saveThatSetupForProjectDone(project) myFixture.configureByFile(fixtureFile) myFixture.launchAction(myFixture.findSingleIntention(intentionToExecute.familyName)) @@ -39,8 +22,6 @@ abstract class IntentionTestBase( * Assert there are no intention [intentionToExecute] in file [fixtureFile] */ protected fun assertNoIntention(fixtureFile: String) { - setupLanguageLevel() - KphpStormConfiguration.saveThatSetupForProjectDone(project) myFixture.configureByFile(fixtureFile) val availableIntentions = myFixture diff --git a/src/test/kotlin/com/vk/kphpstorm/testing/infrastructure/KphpStormTestBase.kt b/src/test/kotlin/com/vk/kphpstorm/testing/infrastructure/KphpStormTestBase.kt new file mode 100644 index 0000000..07b3c43 --- /dev/null +++ b/src/test/kotlin/com/vk/kphpstorm/testing/infrastructure/KphpStormTestBase.kt @@ -0,0 +1,22 @@ +package com.vk.kphpstorm.testing.infrastructure + +import com.intellij.testFramework.fixtures.BasePlatformTestCase +import com.jetbrains.php.config.PhpLanguageLevel +import com.jetbrains.php.config.PhpProjectConfigurationFacade + +abstract class KphpStormTestBase() : BasePlatformTestCase() { + + protected open val languageLevel: PhpLanguageLevel = PhpLanguageLevel.PHP740 + + override fun getTestDataPath() = "src/test/fixtures" + + override fun setUp() { + super.setUp() + setupLanguageLevel() + } + + private fun setupLanguageLevel() { + val projectConfigurationFacade = PhpProjectConfigurationFacade.getInstance(project) + projectConfigurationFacade.languageLevel = languageLevel + } +} diff --git a/src/test/kotlin/com/vk/kphpstorm/testing/infrastructure/TypeTestBase.kt b/src/test/kotlin/com/vk/kphpstorm/testing/infrastructure/TypeTestBase.kt index 4aee7ce..dd2c83b 100644 --- a/src/test/kotlin/com/vk/kphpstorm/testing/infrastructure/TypeTestBase.kt +++ b/src/test/kotlin/com/vk/kphpstorm/testing/infrastructure/TypeTestBase.kt @@ -2,7 +2,6 @@ package com.vk.kphpstorm.testing.infrastructure import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiElement -import com.intellij.testFramework.fixtures.BasePlatformTestCase import com.jetbrains.php.lang.psi.elements.FunctionReference import com.jetbrains.php.lang.psi.elements.PhpPsiElement import com.jetbrains.php.lang.psi.elements.PhpTypedElement @@ -12,8 +11,7 @@ import com.vk.kphpstorm.configuration.KphpStormConfiguration import com.vk.kphpstorm.exphptype.ExPhpTypePipe import com.vk.kphpstorm.helpers.toExPhpType -abstract class TypeTestBase : BasePlatformTestCase() { - override fun getTestDataPath() = "src/test/fixtures" +abstract class TypeTestBase : KphpStormTestBase() { protected open fun runFixture(vararg fixtureFiles: String) { KphpStormConfiguration.saveThatSetupForProjectDone(project)