src/Concerns/MocksApplicationServices.php
protected function withoutModelEvents()
    {
        $mock = Mockery::mock('Illuminate\Contracts\Events\Dispatcher');

        $mock->shouldReceive('dispatch')->andReturnUsing(function ($called) {
            $this->firedModelEvents[] = $called;
        });

        $mock->shouldReceive('until')->andReturnUsing(function ($called) {
            $this->firedModelEvents[] = $called;

            return true;
        });

        $mock->shouldReceive('listen')->andReturnUsing(function ($event, $listener) {
            //
        });

        Model::setEventDispatcher($mock);

        return $this;
    }
protected function withoutModelEvents()
    {
        $mock = Mockery::mock('Illuminate\Contracts\Events\Dispatcher');

        $mock->shouldReceive('dispatch')->andReturnUsing(function ($called) {
            $this->firedModelEvents[] = $called;
        });

        $mock->shouldReceive('until')->andReturnUsing(function ($called) {
            $this->firedModelEvents[] = $called;

            return true;
        });

        $mock->shouldReceive('listen')->andReturnUsing(function ($event, $listener) {
            //
        });

        Model::setEventDispatcher($mock);

        return $this;
    }
protected function withoutModelEvents ( ) { $ mock = Mockery :: mock ( 'Illuminate\Contracts\Events\Dispatcher' ) ; $ mock -> shouldReceive ( 'dispatch' ) -> andReturnUsing ( function ( $ called ) { $ this -> firedModelEvents [ ] = $ called ; } ) ; $ mock -> shouldReceive ( 'until' ) -> andReturnUsing ( function ( $ called ) { $ this -> firedModelEvents [ ] = $ called ; return true ; } ) ; $ mock -> shouldReceive ( 'listen' ) -> andReturnUsing ( function ( $ event , $ listener ) { // } ) ; Model :: setEventDispatcher ( $ mock ) ; return $ this ; }
Mock the model event dispatcher so all Eloquent events are silenced.

@return $this
Mock the model event dispatcher so all Eloquent events are silenced .