Open bakerkretzmar opened 3 months ago
I can confirm the issue in your first example.
In your second example it's working as it is supposed to, actually you are passing only one argument.
It's going through the dataset one by one so it is providing only one argument in your case (Controller::class
in first iteration then Model::class
in second). If you need to pass two your need to rewrite your dataset like:
[
['controller', Controller::class],
['model', Model::class]
.
.
.
]
In this case
'controller'
and the second Controller::class
.'model'
and Model::class
for the second.
and so onAh thanks you're right, missed that. I'll update the examples.
I think this might be happening because Pest is trying to parse any data providers that are 2-element arrays as callables...
Works fine:
test('returns a successful response', function (string $first, string $second) {
expect(true)->toBeTrue();
})->with([Controller::class])->with([User::class, 'update']);
Errors:
test('returns a successful response', function (string $first, string $second) {
expect(true)->toBeTrue();
})->with([Controller::class])->with([User::class, 'notAMethodOnTheUserClass']);
What Happened
If more than one of the values in a single dataset are namespaced class strings Pest fails or errors.
How to Reproduce
The following test causes Pest to error out with the message
Typed static property P\Tests\Feature\ExampleTest::$__latestDescription must not be accessed before initialization
:Changing either
Model::class
orController::class
to a literal string (e.g.'App\Model'
) fixes that particular example, but this doesn't always work.Sample Repository
No response
Pest Version
2.34.4
PHP Version
8.2.15
Operation System
macOS
Notes
This doesn't seem to reproduce consistently. I can make it fail with some class name strings but not others, sometimes using
::class
notation and sometimes with literal strings, etc.