-
Notifications
You must be signed in to change notification settings - Fork 33
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
Erroneous TooFewArguments on combination of data provider and dependent test #113
Comments
Currently the plugin has no idea what
You may try to suppress it via config file. Didn't test it myself, but I think it might work: <TooFewArguments>
<errorLevel type="suppress">
<referencedFunction name="Tests\TestCase::testThatFails" />
</errorLevel>
</TooFewArguments> |
Dev notes:
The following is not really clear:
|
Yep, the following does work: Feature: Suppression
In order to avoid false positives
As a Psalm user
I need to be able to suppress issues emitted by the plugin
Scenario: Can suppress TooFewArguments via config
Given I have the following config
"""
<?xml version="1.0"?>
<psalm totallyTyped="true" %s>
<projectFiles>
<directory name="."/>
<ignoreFiles> <directory name="../../vendor"/> </ignoreFiles>
</projectFiles>
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
<issueHandlers>
<TooFewArguments>
<errorLevel type="suppress">
<referencedFunction name="NS\MyTestCase::testConsumer" />
</errorLevel>
</TooFewArguments>
</issueHandlers>
</psalm>
"""
And I have the following code
"""
<?php
namespace NS;
use PHPUnit\Framework\TestCase;
class MyTestCase extends TestCase
{
public function testProducer(): int
{
return 42;
}
/**
* @depends testProducer
* @dataProvider provide
*/
public function testConsumer(int $provided, int $dependedUpon): void {}
/** @return iterable<int,array{int}> */
public function provide() {
yield [1];
}
}
"""
When I run Psalm
Then I see no errors |
This means that if you make |
I'm curious what would happen if it does? |
Just as written - it doesn't inject any data from data-provided test, I'm just getting |
In my case, test case class has the following structure:
In this case,
testSecond()
method gets$foo = 'foo'
and$bar = 'bar'
arguments; but Psalm reportsTooFewArguments
(probably ignoring dependency if data provider is set).P.S.: Anyone please tell me how to suppress this bug until it gets fixed. Adding
@psalm-suppress TooFewArguments
both in provider or test method docblocks doesn't help.The text was updated successfully, but these errors were encountered: