Point of note my issue is not when running different tests but on a single instance of running test
Feb 24, 2015
10
Level 1
Some eloquent model events are not triggered during testing
Reference to Laravel issue https://github.com/laravel/framework/issues/1181
Am writing tests for my application and having problems with some model events not been fired. I have a model called Organization and inside have the following method for events
static function boot()
{
parent::boot();
static::saving(function ($org)
{
if (is_null($org->slug))
{
$org->slug = \Str::slug($org->name);
}
return $org;
});
static::creating(function($org)
{
$org->id = md5(uniqid($org->name));
return $org;
});
static::created(function ($org)
{
\Session::flash('info','We are setting up your organization. This should take a few minutes');
return $org;
});
I have used dd($org) to test which methods run to completion. both created and saving don't work hence in the end the new organization to be created is not saved in database.
Any help offered is appreaciated
Please or to participate in this conversation.