Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta
#286 3 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
35/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
php
Domínio
testing-qa

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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 😁

Linguagem predominante
PHP
Estrelas
544
Forks
58
Merge médio
2d 1h
PRs com merge (30d)
5

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de phpstan/phpstan-phpunit

Todas as issues de phpstan/phpstan-phpunit

Issues semelhantes

Mais issues de PHP

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.