From b4a7aa92a1cd10156790e6772e7a7388fe36897a Mon Sep 17 00:00:00 2001 From: Oliver Nybroe Date: Mon, 20 Jul 2020 09:16:39 +0200 Subject: [PATCH] fix(line-marker): False positive with method calls (#31) --- CHANGELOG.md | 1 + build.gradle.kts | 11 ++-- detekt-config.yml | 5 +- gradle.properties | 6 +-- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle.kts | 2 +- .../com/pestphp/pest/PestIconProvider.kt | 2 +- .../pest/PestTestRunLineMarkerProvider.kt | 7 ++- src/main/kotlin/com/pestphp/pest/PestUtil.kt | 17 +++---- .../pest/configuration/PestDebugRunner.kt | 5 +- .../PestRunConfigurationHandler.kt | 33 +++++++++--- .../PestRunConfigurationProducer.kt | 36 +++++++------ .../pestphp/pest/types/BaseTypeProvider.kt | 3 +- .../pest/types/ThisFieldTypeProvider.kt | 31 +++++++----- .../pestphp/pest/types/ThisTypeProvider.kt | 4 +- .../pest/PestUtil/IsPestTestFunctionTest.kt | 50 +++++++++++++++++++ .../pest/tests/{ => PestUtil}/PestUtilTest.kt | 7 ++- .../MethodCallNamedIt.php | 3 ++ .../MethodCallNamedTest.php | 3 ++ ...tFunctionCallWithDescriptionAndClosure.php | 5 ++ ...ctionCallWithDescriptionAndHigherOrder.php | 3 ++ ...tFunctionCallWithDescriptionAndClosure.php | 5 ++ ...ctionCallWithDescriptionAndHigherOrder.php | 3 ++ 23 files changed, 177 insertions(+), 67 deletions(-) create mode 100644 src/test/kotlin/com/pestphp/pest/PestUtil/IsPestTestFunctionTest.kt rename src/test/kotlin/com/pestphp/pest/tests/{ => PestUtil}/PestUtilTest.kt (87%) create mode 100644 src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/MethodCallNamedIt.php create mode 100644 src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/MethodCallNamedTest.php create mode 100644 src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/PestItFunctionCallWithDescriptionAndClosure.php create mode 100644 src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/PestItFunctionCallWithDescriptionAndHigherOrder.php create mode 100644 src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/PestTestFunctionCallWithDescriptionAndClosure.php create mode 100644 src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/PestTestFunctionCallWithDescriptionAndHigherOrder.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 506b2ff9..3f0a1039 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ ### Fixed - Plugin require restart as PhpTestFrameworkType does not support dynamic plugins +- Line markers reported false positives with method calls([#31](https://github.com/pestphp/pest-intellij/pull/31)) ## [v0.1.1] ### Added diff --git a/build.gradle.kts b/build.gradle.kts index 6e32d3ce..c5968b34 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,9 +11,11 @@ plugins { // gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin id("org.jetbrains.intellij") version "0.4.21" // gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin - id("org.jetbrains.changelog") version "0.3.2" + id("org.jetbrains.changelog") version "0.4.0" // detekt linter - read more: https://detekt.github.io/detekt/kotlindsl.html - id("io.gitlab.arturbosch.detekt") version "1.10.0-RC1" + id("io.gitlab.arturbosch.detekt") version "1.10.0" + // ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle + id("org.jlleitschuh.gradle.ktlint") version "9.2.1" } // Import variables from gradle.properties file @@ -38,7 +40,7 @@ repositories { } dependencies { implementation(kotlin("stdlib-jdk8")) - detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.10.0-RC1") + detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.10.0") } // Configure gradle-intellij-plugin plugin. @@ -56,6 +58,7 @@ intellij { // Read more: https://detekt.github.io/detekt/kotlindsl.html detekt { config = files("./detekt-config.yml") + buildUponDefaultConfig = true reports { html.enabled = false @@ -107,4 +110,4 @@ tasks { token(System.getenv("PUBLISH_TOKEN")) channels(System.getenv("PUBLISH_CHANNEL")) } -} \ No newline at end of file +} diff --git a/detekt-config.yml b/detekt-config.yml index 743f85f1..6c4f8301 100644 --- a/detekt-config.yml +++ b/detekt-config.yml @@ -3,4 +3,7 @@ formatting: Indentation: - active: true \ No newline at end of file + active: true +style: + ReturnCount: + max: 10 \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index c9875a59..ea3e7c23 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,12 +3,12 @@ pluginGroup = com.pestphp pluginName = Pest -pluginVersion = 0.2.1-alpha.2 +pluginVersion = 0.2.1-alpha.3 pluginSinceBuild = 201 pluginUntilBuild = null platformType = IU -platformVersion = LATEST-EAP-SNAPSHOT +platformVersion = 2020.1.2 platformDownloadSources = true -platformPlugins = com.jetbrains.php:202.6250.23 +platformPlugins = com.jetbrains.php:201.7846.90 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1b16c34a..bb8b2fc2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle.kts b/settings.gradle.kts index 16a8b747..774a6c6c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1 +1 @@ -rootProject.name = "pest-intellij" \ No newline at end of file +rootProject.name = "pest-intellij" diff --git a/src/main/kotlin/com/pestphp/pest/PestIconProvider.kt b/src/main/kotlin/com/pestphp/pest/PestIconProvider.kt index 97ff9386..ad53acad 100644 --- a/src/main/kotlin/com/pestphp/pest/PestIconProvider.kt +++ b/src/main/kotlin/com/pestphp/pest/PestIconProvider.kt @@ -13,4 +13,4 @@ class PestIconProvider : IconProvider() { return null } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/pestphp/pest/PestTestRunLineMarkerProvider.kt b/src/main/kotlin/com/pestphp/pest/PestTestRunLineMarkerProvider.kt index ce0a7586..4b247cec 100644 --- a/src/main/kotlin/com/pestphp/pest/PestTestRunLineMarkerProvider.kt +++ b/src/main/kotlin/com/pestphp/pest/PestTestRunLineMarkerProvider.kt @@ -5,6 +5,7 @@ import com.intellij.psi.PsiElement import com.jetbrains.php.lang.lexer.PhpTokenTypes import com.jetbrains.php.lang.psi.PhpPsiUtil import com.jetbrains.php.lang.psi.elements.FunctionReference +import com.jetbrains.php.lang.psi.elements.impl.FunctionReferenceImpl class PestTestRunLineMarkerProvider : RunLineMarkerContributor() { override fun getInfo(leaf: PsiElement): Info? { @@ -12,12 +13,10 @@ class PestTestRunLineMarkerProvider : RunLineMarkerContributor() { return null } - // return RunLineMarkerContributor.withExecutorActions(getTestStateIcon(getLocationHint(testName), leaf.getProject(), false)); return when { - leaf.parent !is FunctionReference -> null + leaf.parent !is FunctionReferenceImpl -> null (leaf.parent as FunctionReference).isPestTestFunction() -> withExecutorActions(PestIcons.RUN_SINGLE_TEST) else -> null } - } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/pestphp/pest/PestUtil.kt b/src/main/kotlin/com/pestphp/pest/PestUtil.kt index a9560660..737c9cb6 100644 --- a/src/main/kotlin/com/pestphp/pest/PestUtil.kt +++ b/src/main/kotlin/com/pestphp/pest/PestUtil.kt @@ -14,7 +14,6 @@ import com.jetbrains.php.phpunit.PhpUnitUtil import com.jetbrains.php.testFramework.PhpTestFrameworkConfiguration import com.jetbrains.php.testFramework.PhpTestFrameworkSettingsManager - fun PsiElement?.isPestTestFunction(): Boolean { return when (this) { null -> false @@ -33,7 +32,6 @@ fun MethodReference.isPestTestFunction(): Boolean { return reference != null && reference.isPestTestFunction() } - fun FunctionReference.getPestTestName(): String? { return when (val parameter = this.getParameter(0)) { is StringLiteralExpression -> parameter.contents @@ -49,13 +47,12 @@ fun PsiElement?.getPestTestName(): String? { } } - fun PsiFile.isPestTestFile(): Boolean { return when (this) { is PhpFile -> { PsiTreeUtil.findChildrenOfType(this, FunctionReference::class.java) - .asSequence() - .any(FunctionReference::isPestTestFunction) + .asSequence() + .any(FunctionReference::isPestTestFunction) } else -> false } @@ -67,8 +64,8 @@ fun PsiFile.isPestConfigurationFile(): Boolean { fun Project.isPestEnabled(): Boolean { return PhpTestFrameworkSettingsManager - .getInstance(this) - .getConfigurations(PestFrameworkType.getInstance()) - .stream() - .anyMatch { config: PhpTestFrameworkConfiguration -> StringUtil.isNotEmpty(config.executablePath) } -} \ No newline at end of file + .getInstance(this) + .getConfigurations(PestFrameworkType.getInstance()) + .stream() + .anyMatch { config: PhpTestFrameworkConfiguration -> StringUtil.isNotEmpty(config.executablePath) } +} diff --git a/src/main/kotlin/com/pestphp/pest/configuration/PestDebugRunner.kt b/src/main/kotlin/com/pestphp/pest/configuration/PestDebugRunner.kt index e1d766b1..7dc7fa6d 100644 --- a/src/main/kotlin/com/pestphp/pest/configuration/PestDebugRunner.kt +++ b/src/main/kotlin/com/pestphp/pest/configuration/PestDebugRunner.kt @@ -2,8 +2,9 @@ package com.pestphp.pest.configuration import com.jetbrains.php.testFramework.run.PhpTestDebugRunner -class PestDebugRunner private constructor() : PhpTestDebugRunner(PestRunConfiguration::class.java) { +class PestDebugRunner +private constructor() : PhpTestDebugRunner(PestRunConfiguration::class.java) { override fun getRunnerId(): String { return "PestDebugRunner" } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/pestphp/pest/configuration/PestRunConfigurationHandler.kt b/src/main/kotlin/com/pestphp/pest/configuration/PestRunConfigurationHandler.kt index fc8dbc7b..2de9e2af 100644 --- a/src/main/kotlin/com/pestphp/pest/configuration/PestRunConfigurationHandler.kt +++ b/src/main/kotlin/com/pestphp/pest/configuration/PestRunConfigurationHandler.kt @@ -15,32 +15,51 @@ class PestRunConfigurationHandler : PhpTestRunConfigurationHandler { } override fun prepareCommand(project: Project, commandSettings: PhpCommandSettings, exe: String, version: String?) { - // String scriptFile = PhpExecutionUtil.loadHelperScriptAndGetText(project, "behat.php", commandSettings, PestRunConfigurationHandler.class); commandSettings.setScript(exe, false) commandSettings.addArgument("--teamcity") commandSettings.addEnv("IDE_PEST_EXE", exe) - if (!version.isNullOrEmpty()) { commandSettings.addEnv("IDE_PEST_VERSION", version) } } @Throws(ExecutionException::class) - override fun runType(project: Project, phpCommandSettings: PhpCommandSettings, type: String, workingDirectory: String) { + override fun runType( + project: Project, + phpCommandSettings: PhpCommandSettings, + type: String, + workingDirectory: String + ) { throw ExecutionException("Can not run pest with type.") } - override fun runDirectory(project: Project, phpCommandSettings: PhpCommandSettings, directory: String, workingDirectory: String) { + override fun runDirectory( + project: Project, + phpCommandSettings: PhpCommandSettings, + directory: String, + workingDirectory: String + ) { phpCommandSettings.addPathArgument(directory) } - override fun runFile(project: Project, phpCommandSettings: PhpCommandSettings, file: String, workingDirectory: String) { + override fun runFile( + project: Project, + phpCommandSettings: PhpCommandSettings, + file: String, + workingDirectory: String + ) { phpCommandSettings.addPathArgument(file) } - override fun runMethod(project: Project, phpCommandSettings: PhpCommandSettings, file: String, methodName: String, workingDirectory: String) { + override fun runMethod( + project: Project, + phpCommandSettings: PhpCommandSettings, + file: String, + methodName: String, + workingDirectory: String + ) { phpCommandSettings.addPathArgument(file) phpCommandSettings.addArgument(String.format("--filter=/%s$/", methodName.replace(" ", "\\s"))) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/pestphp/pest/configuration/PestRunConfigurationProducer.kt b/src/main/kotlin/com/pestphp/pest/configuration/PestRunConfigurationProducer.kt index 29804d64..4bf9da51 100644 --- a/src/main/kotlin/com/pestphp/pest/configuration/PestRunConfigurationProducer.kt +++ b/src/main/kotlin/com/pestphp/pest/configuration/PestRunConfigurationProducer.kt @@ -14,13 +14,17 @@ import com.jetbrains.php.lang.PhpFileType import com.jetbrains.php.testFramework.run.PhpDefaultTestRunnerSettingsValidator import com.jetbrains.php.testFramework.run.PhpDefaultTestRunnerSettingsValidator.PhpTestMethodFinder import com.jetbrains.php.testFramework.run.PhpTestConfigurationProducer -import com.pestphp.pest.* +import com.pestphp.pest.getPestTestName +import com.pestphp.pest.isPestEnabled +import com.pestphp.pest.isPestTestFile +import com.pestphp.pest.isPestTestFunction +import com.pestphp.pest.isPestConfigurationFile class PestRunConfigurationProducer : PhpTestConfigurationProducer( - VALIDATOR, - FILE_TO_SCOPE, - METHOD_NAMER, - METHOD + VALIDATOR, + FILE_TO_SCOPE, + METHOD_NAMER, + METHOD ) { override fun getConfigurationFactory(): ConfigurationFactory = PestRunConfigurationType.getInstance() @@ -35,7 +39,7 @@ class PestRunConfigurationProducer : PhpTestConfigurationProducer { element: PsiElement? -> + val METHOD = Condition { element: PsiElement? -> return@Condition element.isPestTestFunction() } private val METHOD_NAMER = Function { element: PsiElement? -> @@ -48,16 +52,16 @@ class PestRunConfigurationProducer : PhpTestConfigurationProducer(PhpFileType.INSTANCE, XmlFileType.INSTANCE).toList(), - PhpTestMethodFinder { file: PsiFile, _: String -> - if (file.isPestConfigurationFile()) { - return@PhpTestMethodFinder true - } + setOf(PhpFileType.INSTANCE, XmlFileType.INSTANCE).toList(), + PhpTestMethodFinder { file: PsiFile, _: String -> + if (file.isPestConfigurationFile()) { + return@PhpTestMethodFinder true + } - file.isPestTestFile() - }, - false, - false + file.isPestTestFile() + }, + false, + false ) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/pestphp/pest/types/BaseTypeProvider.kt b/src/main/kotlin/com/pestphp/pest/types/BaseTypeProvider.kt index 9bbd8b1d..9270ae29 100644 --- a/src/main/kotlin/com/pestphp/pest/types/BaseTypeProvider.kt +++ b/src/main/kotlin/com/pestphp/pest/types/BaseTypeProvider.kt @@ -7,6 +7,7 @@ import com.jetbrains.php.lang.psi.elements.ParameterList import com.jetbrains.php.lang.psi.elements.Variable import com.jetbrains.php.lang.psi.elements.impl.FunctionReferenceImpl +@Suppress("UnnecessaryAbstractClass") abstract class BaseTypeProvider { protected fun PsiElement?.isThisVariableInPestTest(): Boolean { if ((this as? Variable)?.name != "this") return false @@ -29,4 +30,4 @@ abstract class BaseTypeProvider { companion object { private val PEST_TEST_FUNCTION_NAMES: Set = setOf("it", "test") } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/pestphp/pest/types/ThisFieldTypeProvider.kt b/src/main/kotlin/com/pestphp/pest/types/ThisFieldTypeProvider.kt index d1d05f80..cb30421c 100644 --- a/src/main/kotlin/com/pestphp/pest/types/ThisFieldTypeProvider.kt +++ b/src/main/kotlin/com/pestphp/pest/types/ThisFieldTypeProvider.kt @@ -3,12 +3,17 @@ package com.pestphp.pest.types import com.intellij.openapi.project.Project import com.intellij.psi.PsiElement import com.intellij.psi.util.PsiTreeUtil -import com.jetbrains.php.lang.psi.elements.* +import com.jetbrains.php.lang.psi.elements.AssignmentExpression +import com.jetbrains.php.lang.psi.elements.FieldReference +import com.jetbrains.php.lang.psi.elements.PhpTypedElement +import com.jetbrains.php.lang.psi.elements.Statement +import com.jetbrains.php.lang.psi.elements.Variable +import com.jetbrains.php.lang.psi.elements.PhpNamedElement import com.jetbrains.php.lang.psi.elements.impl.FunctionReferenceImpl import com.jetbrains.php.lang.psi.resolve.types.PhpType import com.jetbrains.php.lang.psi.resolve.types.PhpTypeProvider4 -class ThisFieldTypeProvider: BaseTypeProvider(), PhpTypeProvider4 { +class ThisFieldTypeProvider : BaseTypeProvider(), PhpTypeProvider4 { override fun getKey(): Char { return '\u0222' } @@ -21,16 +26,16 @@ class ThisFieldTypeProvider: BaseTypeProvider(), PhpTypeProvider4 { val fieldName = fieldReference.name ?: return null return psiElement.containingFile.firstChild.children - .filterIsInstance() - .mapNotNull { it.firstChild } - .filterIsInstance() - .filter { PEST_BEFORE_FUNCTION_NAMES.contains(it.name) } - .mapNotNull { it.parameterList?.getParameter(0) } - .flatMap { PsiTreeUtil.findChildrenOfType(it, AssignmentExpression::class.java) } - .filter { isNeededFieldReference(it.variable, fieldName) } - .mapNotNull { it.value } - .filterIsInstance() - .firstOrNull()?.type + .filterIsInstance() + .mapNotNull { it.firstChild } + .filterIsInstance() + .filter { PEST_BEFORE_FUNCTION_NAMES.contains(it.name) } + .mapNotNull { it.parameterList?.getParameter(0) } + .flatMap { PsiTreeUtil.findChildrenOfType(it, AssignmentExpression::class.java) } + .filter { isNeededFieldReference(it.variable, fieldName) } + .mapNotNull { it.value } + .filterIsInstance() + .firstOrNull()?.type } private fun isNeededFieldReference(psiElement: PsiElement?, fieldName: String): Boolean { @@ -54,4 +59,4 @@ class ThisFieldTypeProvider: BaseTypeProvider(), PhpTypeProvider4 { companion object { private val PEST_BEFORE_FUNCTION_NAMES: Set = setOf("beforeEach", "beforeAll") } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/pestphp/pest/types/ThisTypeProvider.kt b/src/main/kotlin/com/pestphp/pest/types/ThisTypeProvider.kt index a0c6604a..542bfb8e 100644 --- a/src/main/kotlin/com/pestphp/pest/types/ThisTypeProvider.kt +++ b/src/main/kotlin/com/pestphp/pest/types/ThisTypeProvider.kt @@ -6,7 +6,7 @@ import com.jetbrains.php.lang.psi.elements.PhpNamedElement import com.jetbrains.php.lang.psi.resolve.types.PhpType import com.jetbrains.php.lang.psi.resolve.types.PhpTypeProvider4 -class ThisTypeProvider: BaseTypeProvider(), PhpTypeProvider4 { +class ThisTypeProvider : BaseTypeProvider(), PhpTypeProvider4 { override fun getKey(): Char { return '\u0221' } @@ -28,4 +28,4 @@ class ThisTypeProvider: BaseTypeProvider(), PhpTypeProvider4 { companion object { private val TEST_CASE_TYPE = PhpType().add("\\PHPUnit\\Framework\\TestCase") } -} \ No newline at end of file +} diff --git a/src/test/kotlin/com/pestphp/pest/PestUtil/IsPestTestFunctionTest.kt b/src/test/kotlin/com/pestphp/pest/PestUtil/IsPestTestFunctionTest.kt new file mode 100644 index 00000000..52f97e2d --- /dev/null +++ b/src/test/kotlin/com/pestphp/pest/PestUtil/IsPestTestFunctionTest.kt @@ -0,0 +1,50 @@ +package com.pestphp.pest.PestUtil + +import com.pestphp.pest.isPestTestFunction +import com.pestphp.pest.tests.PestLightCodeFixture + +class IsPestTestFunctionTest: PestLightCodeFixture() { + override fun getTestDataPath(): String? { + return "src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest" + } + + fun testMethodCallNamedTestIsNotPestTest() { + val file = myFixture.configureByFile("MethodCallNamedTest.php") + + val testElement = file.firstChild.lastChild.firstChild + + assertFalse(testElement.isPestTestFunction()) + } + + fun testMethodCallNamedItIsNotPestTest() { + val file = myFixture.configureByFile("MethodCallNamedIt.php") + + val testElement = file.firstChild.lastChild.firstChild + + assertFalse(testElement.isPestTestFunction()) + } + + fun testFunctionCallNamedItWithDescriptionAndClosure() { + val file = myFixture.configureByFile("PestItFunctionCallWithDescriptionAndClosure.php") + + val testElement = file.firstChild.lastChild.firstChild + + assertTrue(testElement.isPestTestFunction()) + } + + fun testFunctionCallNamedItWithDescriptionAndHigherOrder() { + val file = myFixture.configureByFile("PestItFunctionCallWithDescriptionAndHigherOrder.php") + + val testElement = file.firstChild.lastChild.firstChild + + assertTrue(testElement.isPestTestFunction()) + } + + fun testFunctionCallNamedTestWithDescriptionAndHigherOrder() { + val file = myFixture.configureByFile("PestTestFunctionCallWithDescriptionAndHigherOrder.php") + + val testElement = file.firstChild.lastChild.firstChild + + assertTrue(testElement.isPestTestFunction()) + } +} \ No newline at end of file diff --git a/src/test/kotlin/com/pestphp/pest/tests/PestUtilTest.kt b/src/test/kotlin/com/pestphp/pest/tests/PestUtil/PestUtilTest.kt similarity index 87% rename from src/test/kotlin/com/pestphp/pest/tests/PestUtilTest.kt rename to src/test/kotlin/com/pestphp/pest/tests/PestUtil/PestUtilTest.kt index b1b9bc88..fb39bfda 100644 --- a/src/test/kotlin/com/pestphp/pest/tests/PestUtilTest.kt +++ b/src/test/kotlin/com/pestphp/pest/tests/PestUtil/PestUtilTest.kt @@ -1,9 +1,10 @@ -package com.pestphp.pest.tests +package com.pestphp.pest.tests.PestUtil import com.intellij.psi.util.PsiTreeUtil import com.jetbrains.php.lang.psi.elements.FunctionReference import com.pestphp.pest.getPestTestName import com.pestphp.pest.isPestTestFunction +import com.pestphp.pest.tests.PestLightCodeFixture import java.util.stream.Collectors class PestUtilTest: PestLightCodeFixture() { @@ -31,4 +32,8 @@ class PestUtilTest: PestLightCodeFixture() { functions.first().getPestTestName() ) } + + fun testIsPestTestFunction() { + + } } \ No newline at end of file diff --git a/src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/MethodCallNamedIt.php b/src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/MethodCallNamedIt.php new file mode 100644 index 00000000..79906074 --- /dev/null +++ b/src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/MethodCallNamedIt.php @@ -0,0 +1,3 @@ +it(); \ No newline at end of file diff --git a/src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/MethodCallNamedTest.php b/src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/MethodCallNamedTest.php new file mode 100644 index 00000000..071d5e9a --- /dev/null +++ b/src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/MethodCallNamedTest.php @@ -0,0 +1,3 @@ +test(); \ No newline at end of file diff --git a/src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/PestItFunctionCallWithDescriptionAndClosure.php b/src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/PestItFunctionCallWithDescriptionAndClosure.php new file mode 100644 index 00000000..61f25294 --- /dev/null +++ b/src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/PestItFunctionCallWithDescriptionAndClosure.php @@ -0,0 +1,5 @@ +assertTrue(true); +}); \ No newline at end of file diff --git a/src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/PestItFunctionCallWithDescriptionAndHigherOrder.php b/src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/PestItFunctionCallWithDescriptionAndHigherOrder.php new file mode 100644 index 00000000..869cddc2 --- /dev/null +++ b/src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/PestItFunctionCallWithDescriptionAndHigherOrder.php @@ -0,0 +1,3 @@ +assertTrue(true); \ No newline at end of file diff --git a/src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/PestTestFunctionCallWithDescriptionAndClosure.php b/src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/PestTestFunctionCallWithDescriptionAndClosure.php new file mode 100644 index 00000000..17cdc712 --- /dev/null +++ b/src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/PestTestFunctionCallWithDescriptionAndClosure.php @@ -0,0 +1,5 @@ +assertTrue(true); +}); \ No newline at end of file diff --git a/src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/PestTestFunctionCallWithDescriptionAndHigherOrder.php b/src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/PestTestFunctionCallWithDescriptionAndHigherOrder.php new file mode 100644 index 00000000..205442a8 --- /dev/null +++ b/src/test/resources/com/pestphp/pest/PestUtil/IsPestTestFunctionTest/PestTestFunctionCallWithDescriptionAndHigherOrder.php @@ -0,0 +1,3 @@ +assertTrue(true); \ No newline at end of file