From 1283832dcf1d73837eb7302dbb1ae8339ecc4bd6 Mon Sep 17 00:00:00 2001 From: Oliver Nybroe Date: Wed, 31 May 2023 08:25:18 +0200 Subject: [PATCH] fix: Fix name casing inspection --- CHANGELOG.md | 1 + gradle.properties | 2 +- .../pest/inspections/InvalidTestNameCaseInspection.kt | 7 ++++++- .../pestphp/pest/inspections/InvalidTestNameCase.after.php | 4 ++++ .../com/pestphp/pest/inspections/InvalidTestNameCase.php | 4 ++++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94b47a8d..063ba5bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Fixed file icon missing if all tests has property calls - Fixed gutter icon not updating state correctly - Fixed test names with `[` and `]` not being matched correctly +- Fixed test name casing inspection not working correctly with `it` tests ## 1.9.2 - 2023-03-01 diff --git a/gradle.properties b/gradle.properties index ff15e2fd..08446997 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ pluginGroup = com.pestphp pluginName = PEST PHP -pluginVersion = 1.9.3-EAP.2 +pluginVersion = 1.9.3 # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html # for insight into build numbers and IntelliJ Platform versions. diff --git a/src/main/kotlin/com/pestphp/pest/inspections/InvalidTestNameCaseInspection.kt b/src/main/kotlin/com/pestphp/pest/inspections/InvalidTestNameCaseInspection.kt index 5b830737..548543ea 100644 --- a/src/main/kotlin/com/pestphp/pest/inspections/InvalidTestNameCaseInspection.kt +++ b/src/main/kotlin/com/pestphp/pest/inspections/InvalidTestNameCaseInspection.kt @@ -22,7 +22,12 @@ class InvalidTestNameCaseInspection : PhpInspection() { file.getPestTests() .groupBy { it.getPestTestName() } .filterKeys { it != null } - .filterKeys { !it!!.contains(' ') } + .filterKeys { + // Remove `it ` prefix from test names + val testName = if (it!!.startsWith("it ")) it.substring(3) else it + + !testName.contains(' ') + } .filterKeys { it!!.splitToWords().joinToString(" ") != it } .forEach { declareProblemType(holder, it.value) diff --git a/src/test/resources/com/pestphp/pest/inspections/InvalidTestNameCase.after.php b/src/test/resources/com/pestphp/pest/inspections/InvalidTestNameCase.after.php index 626e0668..dee736e9 100644 --- a/src/test/resources/com/pestphp/pest/inspections/InvalidTestNameCase.after.php +++ b/src/test/resources/com/pestphp/pest/inspections/InvalidTestNameCase.after.php @@ -3,3 +3,7 @@ test('basic test', function () { $this->assertTrue(true); }); + +it('is basic test', function () { + $this->assertTrue(true); +}); \ No newline at end of file diff --git a/src/test/resources/com/pestphp/pest/inspections/InvalidTestNameCase.php b/src/test/resources/com/pestphp/pest/inspections/InvalidTestNameCase.php index 96491e00..afdf233a 100644 --- a/src/test/resources/com/pestphp/pest/inspections/InvalidTestNameCase.php +++ b/src/test/resources/com/pestphp/pest/inspections/InvalidTestNameCase.php @@ -3,3 +3,7 @@ test('basic_test', function () { $this->assertTrue(true); }); + +it('is_basic_test', function () { + $this->assertTrue(true); +}); \ No newline at end of file