Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dhakalsuresh/edd29d495b9f2bac8190798b75e32ec3 to your computer and use it in GitHub Desktop.
Save dhakalsuresh/edd29d495b9f2bac8190798b75e32ec3 to your computer and use it in GitHub Desktop.
Unit test for Laravel join
$this->connectionMock->shouldReceive('table')->once()->andReturn($this->builderMock);
$this->builderMock->shouldReceive('join')->with('table_name AS sa', m::on(function ($join) {
$this->builderMock->shouldReceive('where')->andReturn($this->builderMock);
$query = $this->builderMock->shouldReceive('on')
->andReturn($this->builderMock)
->getMock();
$join($query);
return true;
}))->andReturn($this->builderMock);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment