I'm doing some unit testing and want to test so basic stuff. In my test I'mg using Illuminate\Foundation\Testing\WithoutEvents.
When an user registers he or she get's an activation mail. First I used an Observer for that, but came to the conclusion that Laravel doesn't disable the observers when using WithoutEvents as writen here and here. Then I changed my code to the 'traditional' event and listeners.
EventServiceProvider is still default, except for the $listen property:
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
'App\Events\UserCreated' => [
'App\Listeners\CreateActivation'
],
];
When I dispatch the event:
event(new UserCreated($user));
And an example test (which fails):
class ExampleTest extends TestCase
{
use DatabaseMigrations, WithoutEvents;
public function testExample()
{
$user = factory(User::class)->create();
}
}
The error:
I've no clue why it's is crashing. Any help is much appreciated. Also, if I need to provide more code let me know. Because I'm not sure where the problem is caused.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire