Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Offen
#286 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
php
Bereich
testing-qa

Rechercherichtung

Start by reproducing the issue with the shown testSearch method, its Depends and DataProvider attributes, and providerSearchCases generator. Trace how the extension combines dependent-test arguments with data-provider arguments, then verify that the valid four-parameter method produces no arguments.count diagnostic. No repository file or existing test is named in the issue.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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 😁

Vorherrschende Sprache
PHP
Sterne
544
Forks
58
Ø Merge
2 T. 1 Std.
Gemergte PRs (30 T.)
5

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus phpstan/phpstan-phpunit

Alle Issues in phpstan/phpstan-phpunit

Ähnliche Issues

Weitere Issues zu PHP

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.