php - BadMethodCallException: Method Mockery_0_Illuminate_Contracts_Events_Dispatcher::listen() does not exist on this mock object -


i'm doing unit testing , want test basic stuff. in test i'mg using illuminate\foundation\testing\withoutevents.

when user registers or get's activation mail. first used observer that, came conclusion laravel doesn't disable observers when using withoutevents writen here , here. changed code 'traditional' event , listeners.

eventserviceprovider still default, except $listen property:

/**  * event listener mappings application.  *  * @var array  */ protected $listen = [     'app\events\usercreated' => [         'app\listeners\createactivation'     ], ]; 

when dispatch event:

event(new usercreated($user));

and example test (which fails):

class exampletest extends testcase {     use databasemigrations, withoutevents;      public function testexample()     {         $user = factory(user::class)->create();     } } 

the error:

error

i've no clue why it's crashing. appreciated. also, if need provide more code let me know. because i'm not sure problem caused.

as said before in question, withoutevents doesn't disable observers. can see in error problem not userobserver or events, sluggable package. package had observer well, creating error.

instead of $user = factory(user::class)->create(); created function in tests/testcase.php creates activated user so:

public function activateduser($attributes = []) {     $user = factory(user::class)->create($attributes);      db::table('activations')->where('user_id', $user->id)->delete();      return $user; } 

so in tests can create activated users: $user = $this->activateduser();


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -