pestphp / pest

Pest is an elegant PHP testing Framework with a focus on simplicity, meticulously designed to bring back the joy of testing in PHP.
https://pestphp.com
MIT License
9.06k stars 313 forks source link

[Bug]: Error when running test using a forelse #1147

Open felipeArnold opened 2 months ago

felipeArnold commented 2 months ago

What Happened

My livewire component expects to receive a collection or null, when receiving null and running the test, using the @forelse directive, it reports an error in the test saying that "Illuminate\View\ViewException: foreach() argument must be of type array|object, null given", adding an if around foreach works normally, follow images for better viewing.

public ?Collection $comments = null;

How to Reproduce

image image image image

Sample Repository

No response

Pest Version

v2.34.7

PHP Version

8.3

Operation System

Windows

Notes

No response

devajmeireles commented 2 months ago

Have you tried inserting a @dd to debug the value inside the comments?

felipeArnold commented 2 months ago

yes, returns null