Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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 <warning> and <error> 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <caret>
* 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))
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
Loading