Skip to content

Commit

Permalink
Merge pull request #61 from pestphp/fix-duplicate-test-inspection
Browse files Browse the repository at this point in the history
fix(inspection): Fixed duplicate test inspection when no name on the test yet
  • Loading branch information
olivernybroe authored Sep 4, 2020
2 parents 40b971c + 7118a86 commit d3fddcd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
### Removed

### Fixed
- Fixed duplicate test name error when no test name is given yet. ([#61](https://github.com/pestphp/pest-intellij/pull/61))

### Security
## [0.3.3]
Expand Down
16 changes: 15 additions & 1 deletion src/main/kotlin/com/pestphp/pest/GithubErrorReporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import com.intellij.openapi.diagnostic.ErrorReportSubmitter
import com.intellij.openapi.diagnostic.IdeaLoggingEvent
import com.intellij.openapi.diagnostic.SubmittedReportInfo
import com.intellij.openapi.extensions.PluginId
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ProjectManager
import com.intellij.util.Consumer
import com.jetbrains.php.testFramework.PhpTestFrameworkSettingsManager
import com.jetbrains.php.testFramework.PhpTestFrameworkVersionCache
import java.awt.Component
import java.io.UnsupportedEncodingException
import java.net.URLEncoder
Expand Down Expand Up @@ -39,6 +43,9 @@ class GithubErrorReporter : ErrorReportSubmitter() {
val body = event?.throwableText ?: "Please paste the full stacktrace from the IDEA error popup."
val version = PluginManagerCore.getPlugin(PluginId.getId("com.pestphp.pest-intellij"))?.version

val project: Project? = ProjectManager.getInstance().openProjects.first()
val pestVersion = getPestVersion(project)

val builder = StringBuilder(URL)
try {
builder.append(URLEncoder.encode(title, ENCODING))
Expand All @@ -50,7 +57,7 @@ class GithubErrorReporter : ErrorReportSubmitter() {
|| ---------------- | -----
|| Bug report? | yes
|| Plugin version | $version
|| Pest version | x.y.z
|| Pest version | $pestVersion
|| OS | ${System.getProperty("os.name")}
|
|### Description
Expand Down Expand Up @@ -85,4 +92,11 @@ class GithubErrorReporter : ErrorReportSubmitter() {
)
return true
}

private fun getPestVersion(project: Project?): String {
return PhpTestFrameworkSettingsManager.getInstance(project)
.getLocalConfig(PestFrameworkType.instance)?.let {
PhpTestFrameworkVersionCache.getCache(project, it)
} ?: "x.y.z"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class DuplicateTestNameInspection : PhpInspection() {
return object : PhpElementVisitor() {
override fun visitPhpFile(file: PhpFile) {
file.getPestTests()
.groupBy { it.getPestTestName()!! }
.groupBy { it.getPestTestName() }
.filterKeys { it != null }
.filter { it.value.count() > 1 }
.forEach {
declareProblemType(holder, it.value)
Expand Down

0 comments on commit d3fddcd

Please sign in to comment.