fahad
262
3
Testing

Mock Error in PhpUnit test

Posted 4 months ago by fahad

I am always getting error while writing a simple test, don't know what's wrong there, any sort of help is highly appreciated.

Method pluck(<Any Arguments>) from Mockery_6_App_Models_EmailList should be called
 exactly 1 times but called 0 times

My Method is as below:


public function getDoNotEmailers(EmailList $list)
{
   return $list->pluck('email');
} 

and My test

class getDoNotEmailersTest extends TestCase{

  public function testGetDoNotEmail()
  {
     $mock = Mockery::mock('App\Models\EmailList');

     $mock->shouldReceive('pluck')->once()->andReturn('abracadebra'):

     $list = new EmailList(['email' => '[email protected]'])
     $actual = $this->sut->getDoNotEmailers($list):
 
  }
}


Please sign in or create an account to participate in this conversation.