Laravel Queue::shouldReceive()
laravel, laravel-4, mockery, unit-testing
Solution
Putting `Queue::shouldReceive('connected')->once();` after `Queue::shouldReceive('push')->once();` solved this.
Problem
I have the following in one of my routes ``` $rules = array( 'name' => 'Required', 'subject' => 'Required', 'message' => 'Required', 'email' => 'Required|Email', 'recaptcha_response_field' => 'required|recaptcha' ); $validator = Validator::make(Input::all(), $rules); if($validator->fails()){ return Redirect::to('contact')->withInput()->withErrors($validator); }else{ $data = array('name' => Input::get('name'), 'email' => Input::get('email'), 'text' => Input::get('message'), 'subject' => Input::get('subject')); Queue::push('ContactQueue', $data); return Redirect::to('contact')->with('success', 'Message sent successfully'); } ``` I am trying to write a unit test for the success scenario, I have the following: ``` public function testSuccess(){ Validator::shouldReceive('make')->once()->andReturn(Mockery::mock(['fails' => false])); Queue::shouldReceive('push')->once(); $this->call('POST', '/contact'); $this->assertRedirectedTo('/contact'); } ``` But I keep receiving the following error when trying to run phpunit: `BadMethodCallException: Method Illuminate\Queue\QueueManager::connected() does not exist on this mock object` Any ideas?