-
-
Notifications
You must be signed in to change notification settings - Fork 479
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
Model Factory from Unit test does not trigger model events #428
Comments
Hey there.. Is this specifically related to Unit-Tests or the model-events in general? |
When you call the model factory from seeder it's working fine, |
i am not entirely sure,.. but i think, i once read something, that the seeders may "disable" the events.. because usually you want to dump a f*cking lot of data at once.. maybe this can be the issue!? |
But with seeders is working fine. when you call seeders directly not from UnitTests |
and it works in a regular laravel project? just to cross "phpunit" from the list? ;) |
In regular laravel project it works. |
hm, ok.. now i get it - sorry ;) |
This issue is related with apiato/core, my mistake adding it here |
thank you very much for the feedback and your time / effort to further investigate this issue! I will take a look at it shortly 👍 |
@johannesschobel I have create the pull request on apiato/core which will solve this issue. |
î've seen it.. will take a closer look later and then merge.. thanks a lot.. |
i will close the issue here, as we have another issue in |
Calling model factory create in unit test
for example
factory(App\User::class)->create()
Will not trigger Model Events (https://laravel.com/docs/5.6/eloquent#events)
Steps to Reproduce the Problem
Create the following Observers https://laravel.com/docs/5.6/eloquent#observers
In for example User Container add some User factory and call it from unit tests you
will see that model events are not triggered.
Specifications
Additional Details
I have tested the same behavior with laravel 5.6 and the events are fired
While debugging this bug in apiato I came to
The custom apiato eventserviceprovider
\Apiato\Core\Abstracts\Events\Providers\EventServiceProvider
If we comment the loading of this provider in
\Apiato\Core\Providers\ApiatoProvider::$serviceProviders
the model event will be triggered.
Maybe the order of provider register should be different, need more time to debug.
Please advice if you already have a solution.
The text was updated successfully, but these errors were encountered: