Skip to content

Argument count error in PHPUnit test with data provider and depends attribute #286

@mitelg

Description

@mitelg

Bug report

hey there 👋

I think I found an issue within PHPUnit tests, using the Depends and DataProvider attribute on the same test method.

    public function testIndexing(): IdsCollection
    {
        $ids = new IdsCollection();
        // ...

        return $ids;
    }

    /**
     * @param list<string> $config
     * @param list<string> $expectedProducts
     */
    #[Depends('testIndexing')]
    #[DataProvider('providerSearchCases')]
    public function testSearch(array $config, string $term, array $expectedProducts, IdsCollection $ids): void
    {
        // ...
    }

    /**
     * @return \Generator<string, array{list<string>, string, list<string>}>
     */
    public static function providerSearchCases(): \Generator
    {
        yield 'search for manufacturer' => [
            ['name', 'description', 'customSearchKeywords', 'manufacturer.name'],
            'Shopware',
            ['product-4'],
        ];

        // and more
    }

error:

Method Shopware\TestClassName::testSearch() invoked with 3 parameters, 4 required.  
🪪  arguments.count   

Unfortunately I cannot provide a playground code snippet, as PHPUnit is not available there. I also don't know, if this is a problem of the PHPUnit extension.

Expected output

no error

Did PHPStan help you today? Did it make you happy in any way?

PHPStan helps me everyday to be the last stand against AI slop 😁

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions