X Tutup
Skip to content

Draft: Pest Extension#2502

Open
einenlum wants to merge 2 commits intophpactor:masterfrom
einenlum:feature/pest-extension
Open

Draft: Pest Extension#2502
einenlum wants to merge 2 commits intophpactor:masterfrom
einenlum:feature/pest-extension

Conversation

@einenlum
Copy link
Collaborator

@einenlum einenlum commented Jan 12, 2024

Only a very early draft for now.

Not sure where I'm going with this but if you have some input/suggestions, it's very welcome 💙. It seems to me at first that it should be a TolerantCompletor but maybe I'm on the wrong track.

Tries solving #2344.

Goals:

  • Suggest Pest if it's installed
  • Suggest completion if in a test file (for that we need to detect we're in a closure and suggest methods to $this as if it were bound to a TestCase class)
  • For a first step, give completions from PHPUnit\Framework\TestCase if in Unit folder and from Tests\TestCase if in Feature folder. Not sure yet, but I think Illuminate\\Foundation\\Testing\\RefreshDatabase is only used by default if pest laravel plugin is installed (I need to check that).
  • Then it would be great to analyze the Pest.php to check which TestCase is used in which folder.

@dantleech
Copy link
Collaborator

dantleech commented Jan 12, 2024

Suggest completion if in a test file

I think it's less about "completion" and more about telling the static analyser what $this is in a Closure.

This is currently done via. frame walkers which are registered with a tag here. So you could imagine registering a walker for the Closure node type, then you can $frame->set(new Variable('this', TypeFactory::reflectedClassType($reflector, 'Whatever\It\Is')) or whatever the syntax is.

No warranty on this behavior though, this is probably uncharted territory 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup