Skip to content

Commit

Permalink
Fixed dataset reference error when no dataset provided yet
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver committed Jun 7, 2022
1 parent 2975dbb commit 0fdef63
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
- Changed goto and completion contributor to reference provider
- Changed icons to use build-in dark mode switching

### Fixed
- Fixed dataset reference error when no dataset provided yet.

## [1.6.2]
### Fixed
- Fixed duplicate type provider key with nette plugin
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pluginGroup = com.pestphp
pluginName = PEST PHP
pluginVersion = 1.7.0-EAP.3
pluginVersion = 1.7.0-EAP.4

# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ class InvalidDatasetReferenceInspection : PhpInspection() {

file.getPestTests()
// Has to be a method reference, as else there is no dataset
.asSequence()
.filterIsInstance<MethodReferenceImpl>()
.filter { it.name == "with" }
.mapNotNull { it.parameters[0] }
.mapNotNull { it.parameters.getOrNull(0) }
.filterIsInstance<StringLiteralExpression>()
.filter { it.contents !in localDatasets && it.contents !in sharedDatasets }
.toList()
.forEach {
declareProblemType(
holder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ class InvalidDatasetReferenceInspectionTest : PestLightCodeFixture() {

myFixture.checkHighlighting()
}

fun testHasWithStatementWithNoArgs() {
myFixture.configureByFile("DatasetNoArgsTest.php")

myFixture.checkHighlighting()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

dataset('dojos', [
'Cobra Kai',
'Eagle Fang',
'Miyagi Do'
]);


it('can check if in the valley', function (string $dojo) {

})->with();

0 comments on commit 0fdef63

Please sign in to comment.