logo

A surprising issue with the Auth user and tests

And why it happens

Joel Clermont
Joel Clermont
2025-09-26

In a previous video, I talked about one aspect of Eloquent strictness checks: lazy loading.

In today's video, I want to show a surprising issue with another strictness check: missing attribute access.

When working with factory-generated data in a test, you might get an exception with this strictness check, when you really wouldn't expect one.

Let's see why it works this way, and how to prevent it from making our tests fail.

Watch Now (6 min)

And after watching, don't forget to subscribe to our YouTube channel, so you don't miss future videos.

Here to help,

Joel

P.S. Eloquent strictness is one easy way to get more confident with your code. Ash has published a helpful guide with many more tips to make your Laravel apps "battle ready".

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
email
No spam. Only real-world advice you can use.