Argument count error in PHPUnit test with data provider and depends attribute
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- php
- Domain
- testing-qa
Research direction
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.
Written by the indexing model from the issue text.
Description
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 😁
- Dominant language
- PHP
- Stars
- 544
- Forks
- 58
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 5
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from phpstan/phpstan-phpunit
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
phpstan/phpstan-phpunit#332 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
phpstan/phpstan-phpunit#321 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
phpstan/phpstan-phpunit#309 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
phpstan/phpstan-phpunit#299 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
phpstan/phpstan-phpunit#292 · 3 comments ·
All issues in phpstan/phpstan-phpunit
Similar issues
-
a11y admissions.uiowa.edu needs grooming SiteImprove best practice
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Save States Menu Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
pluginsGLPI/datainjection#673 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
octobercms/october#6130 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
getgrav/grav-plugin-form#656 ·