03.12.2015 Views

laravel4cookbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Controller Testing 374<br />

151 }<br />

152<br />

153 protected function getMailerMock()<br />

154 {<br />

155 return Mockery::mock("Formativ\PostMailerInterface")<br />

156 ->makePartial();<br />

157 }<br />

158<br />

159 protected function getResponseMock()<br />

160 {<br />

161 return Mockery::mock("Illuminate\Support\Facades\Response")<br />

162 ->makePartial();<br />

163 }<br />

164<br />

165 protected function getDispatcherMock()<br />

166 {<br />

167 return Mockery::mock("Illuminate\Events\Dispatcher")<br />

168 ->makePartial();<br />

169 }<br />

170 }<br />

.<br />

This file should be saved as app/tests/controllers/PostControllerTest.php.<br />

Here we’re still testing method calls, but we also test multiple paths through the store() method.<br />

.<br />

We haven’t used any assertions, even though they are very useful for unit and functional testing.<br />

Feel free to use them to check output values…<br />

.<br />

You can find out more about Mockery at: https://github.com/padraic/mockery.<br />

https://github.com/padraic/mockery

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!