Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for using Finder objects for uses() #312

Closed
wants to merge 5 commits into from
Closed

feat: add support for using Finder objects for uses() #312

wants to merge 5 commits into from

Conversation

owenvoke
Copy link
Member

@owenvoke owenvoke commented Jun 9, 2021

Q A
Bug fix? no
New feature? yes
Fixed tickets #...

This came up on Discord where it was asked whether it was possible to provide something such as globs (e.g. **/Feature) to the uses()->in() call. This will basically throw a ShouldNotHappen exception if the Finder class doesn't exist, and the usual uses()->in() call can be used as normal.

For example, here's how you could specify all Feature subdirectories to use a specific testcase class.

use Symfony\Component\Finder\Finder;

uses(Tests\TestCase::class)->inFinder(
    Finder::create()
        ->name('Feature')
        ->directories()
        ->in(__DIR__)
);

@devatreides
Copy link

devatreides commented Jun 9, 2021

You can just set the dir name (in this case, "__DIR__") and the Finder class will keep looking recursively.

use Symfony\Component\Finder\Finder;

uses(Tests\TestCase::class)->inFinder(
    Finder::create()
        ->name('Feature')
        ->directories()
        ->in(__DIR__)
);

Just to be clear, the parameter is a Finder instance for not add Symfony/Finder to Pest dependencies?

@owenvoke
Copy link
Member Author

owenvoke commented Jun 9, 2021

Yeah, the parameter is a Symfony\Component\Finder\Finder instance, but I wasn't sure whether to add it as a dependency for now. It's just suggested if people want to use it.

@nunomaduro
Copy link
Member

Can’t we make the “in” method accept a string or a instance of Finder?

@nunomaduro
Copy link
Member

Also, can you add a test for this? Maybe add a new folder that extends a specific test case.

@nunomaduro
Copy link
Member

cc @owenvoke

@owenvoke
Copy link
Member Author

Apologies, I'd lost track of this. I'd thought about adding it directly to the in() call. I guess I can do that. 👍🏻

@nunomaduro
Copy link
Member

@owenvoke What's the current state of this pull request?

@nunomaduro
Copy link
Member

No plans for this, thanks!

@nunomaduro nunomaduro closed this Jul 26, 2021
@owenvoke owenvoke deleted the feature/symfony-finder branch May 12, 2022 17:30
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.

3 participants