Support the ongoing development of Laravel.io →
posted 10 years ago
Testing

Hey, I have a booking system and created a simplistic testBooking class with 3-4 methods that each test different scenarios. If I run them separetly in PHPStorm, each method with a created $booking class I can $booking->delete(). But when I run the whole testBooking class at once No $booking->delete()'s are fired...Nor is the event listeners I have for registered.

Is this a known issue? I've googled some of it and found there are issues, but that a model can't even ->delete()'ed?

Anyone?

Btw, I do have set a function in TestCase that loops all models and flush listeners. But, no difference.

Last updated 3 years ago.
0

This was discussed in https://github.com/laravel/framework/issues/1181 but that is no longer there now :(.

My solution involved using:

Model::flushEventListeners(); Model::boot();

before each test. If you are only flushing the listeners I would expect it to not work.

How you do this is up to you. I just ended up putting it in __before() but I havent needed to copy that into very many tests yet.

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

CedNet cednet Joined 16 Dec 2013

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.