Skip to content
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

[Bug]: Dataset with named parameters fails in Pest 3 if parameters count mismatch #1232

Open
lukasleitsch opened this issue Sep 11, 2024 · 0 comments
Labels

Comments

@lukasleitsch
Copy link

lukasleitsch commented Sep 11, 2024

What Happened

We use shared datasets to provide data for multiple tests. The dataset uses keys to make the data readable. Not all tests require all parameters from the datasets. So, the dataset contains more items in the array than the parameters needed by the tests.

In Pest 2, this works without any issues. In Pest 3, this setup fails.

It would be great to have the same behavior in Pest 3 as in Pest 2. I want to avoid adding unnecessary parameters to tests that are not used in the test.

In the sample repository, I provide an example.

How to Reproduce

  • Clone the sample repository
  • Run composer install
  • Run ./vendor/bin/pest
  • The tests fail with this error
   FAILED  Tests\Unit\ExampleTest > dataset with less parameters count with (1, 1, 1) #2                   Error
  Unknown named parameter $parameterC
  str_replace(): Argument #3 ($subject) must be of type array|string, null given

  at vendor/filp/whoops/src/Whoops/Exception/FrameCollection.php:43
     39▕      * @return FrameCollection
     40▕      */
     41▕     public function filter($callable)
     42▕     {
  ➜  43▕         $this->frames = array_values(array_filter($this->frames, $callable));
     44▕         return $this;
     45▕     }
     46▕
     47▕     /**
  • Change the pest version in the composer.json to ^2.0
  • Reinstall the dependencies
  • Run ./vendor/bin/pest
  • The tests pass

Sample Repository

https://github.com/lukasleitsch/pest-issue

Pest Version

3.0.4

PHP Version

8.3.11

Operation System

macOS

Notes

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant