Giter Club home page Giter Club logo

Comments (14)

olivernybroe avatar olivernybroe commented on July 18, 2024 16

A workaround which could make this work without an IDE, would be to supply the class as the first argument in the function.

it('foo', function (TestCase $test) {
    $test->assertFoo;
});

$this can still be there, but if users want autocompletion they can do it like that.
Ofc. a PHPStorm plugin can do so it won't be needed in PHPStorm, but this solution could do so it can be used in vscode and so on.

from pest.

petemcfarlane avatar petemcfarlane commented on July 18, 2024 16

I don't know if it's relevant to this issue exactly, but the biggest thing preventing me adopting pest is the PHPStorm integration with the test runner.

I've no idea how it works, sorry, but I know they support PHPUnit, PhpSpec and Behat and I think Codeception.

Screenshot 2020-05-28 at 15 18 21

This would be super useful for PHPStorm users! ❤️

from pest.

tbtmuse avatar tbtmuse commented on July 18, 2024 7

I can look into creating a Pest plugin for PHPStorm. Need a bit of a refresher first, I last worked on an intelliJ plugin a while ago.

This will most probably be a "Custom Language Support" plugin, but a "Framework Integration" plugin might allow for more functionality in future.

from pest.

olivernybroe avatar olivernybroe commented on July 18, 2024 5

So I can see we never updated this issue, there is a repository for the plugin and with a lot of working features.
A stable release has not been made yet, however it is pretty usable already.

https://github.com/pestphp/pest-intellij

@christophrumpel what you are asking for is possible in the plugin now btw.

from pest.

nunomaduro avatar nunomaduro commented on July 18, 2024 2

I got in touch with PHPStorm team. They told me this is something that can be accomplished doing a plugin. We just need to find someone with the expertises to do it. I guess is just a question of having Pest open sourced. 👍

from pest.

BertvanHoekelen avatar BertvanHoekelen commented on July 18, 2024 1

This has also implications on the beforeEach methods. Dynamically defined properties are not "seen" by PHPStorm.

For example:

<?php 

beforeEach(function () {
    /* @var \Tests\TestCase $this */

    $this->fooMock = Mockery::mock(Foo::class);
    $this->fooMock->shouldReceive('execute')->andReturnTrue();
});

it('recognises dynamic properties', function () {
    /* @var \Tests\TestCase $this */
    
    $this->fooMock->expects('foo'); // No autocomplete on fooMock
});

Currently I can't seem to find a workaround for this.

from pest.

tbtmuse avatar tbtmuse commented on July 18, 2024 1

Perfect thanks.

from pest.

christophrumpel avatar christophrumpel commented on July 18, 2024 1

Hey people, just tried out the package and I really enjoy writing tests like that. (I didn't thought I would hehe)

For me missing right now is also more support for PhpStorm before I would integrate it in my daily workflow. Like @petemcfarlane said, being able to use PhpStorm's Test Runner would be awesome. I'm really used to go into a test and use a shortcut to run the current test, where my cursor is, or all tests of the current file. Not sure if this would be possible with a plugin?

That's just my first feedback regarding PEST and PhpStorm. Again thanks for the package 👍

from pest.

nunomaduro avatar nunomaduro commented on July 18, 2024

@tbtmuse That would be awesome. The PHPStorm core team told me that we should take a look into this: https://github.com/Haehnchen/idea-php-symfony2-plugin for grabbing some ideas.

from pest.

JoshMoreno avatar JoshMoreno commented on July 18, 2024

@nunomaduro Any reason to not do what @olivernybroe suggested?
As he said, this would benefit developers that don't use phpstorm and $this can still be bound making this completely optional for the developer. And we wouldn't require a separate phpstorm plugin that someone has to end up maintaining.

from pest.

nunomaduro avatar nunomaduro commented on July 18, 2024

Concerning autocompletions, the problem will be addressed in Pest 0.2.

from pest.

jonnywilliamson avatar jonnywilliamson commented on July 18, 2024

I don't know if it's relevant to this issue exactly, but the biggest thing preventing me adopting pest is the PHPStorm integration with the test runner.

I got a little bit further using PEST a few days ago to run tests in phpstorm. It's a bit ugly.

But unfortunately I had to give up as PHPStorm just doesn't seem ready yet for Pest.

https://github.com/pestphp/website/issues/39

from pest.

JoshMoreno avatar JoshMoreno commented on July 18, 2024

@petemcfarlane @jonnywilliamson
I know this isn't ideal, but since pest passes all args to PHPUnit I've been using --filter for now. I'd much rather have it mapped to a keystroke but this will do for now.

With a test that looks like this...
```php
// RegisterTest.php

it('requires a password to be at least 8 characters', function () {
    // ...
});

Then run your tests...

# run a single file
./vendor/bin/pest --filter RegisterTest

# run a specific test (pretty cool this works!)
./vendor/bin/pest --filter 'requires a password to be at least 8 characters'

And if you want to make it shorter, create the following aliases. I have these in my ~/.zshrc.

alias pest="./vendor/bin/pest"
alias pestf="./vendor/bin/pest --filter"

If anyone wants to help out, I opened an issue so we can get the cli documented with examples; just been so busy lately!
See #17

from pest.

olivernybroe avatar olivernybroe commented on July 18, 2024

Has anybody looked into this yet?

I think it makes sense to register pest as a new framework type, to have full control instead of trying to build on top of phpunit. At least my limited experience with plugin creation, says that building on top of the build in types often gives problems because there will be a lot of deprecations in future versions of phpstorm.

So I am thinking something in the likes of this?
image

image

from pest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.