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 371<br />

25 [$repositoryMock, "insert"]<br />

26 );<br />

27<br />

28 $dispatcherMock<br />

29 ->shouldReceive("listen")<br />

30 ->atLeast()<br />

31 ->once()<br />

32 ->with(<br />

33 "post.store",<br />

34 [$mailerMock, "send"]<br />

35 );<br />

36<br />

37 $postController = new PostController(<br />

38 $repositoryMock,<br />

39 $this->getValidatorMock(),<br />

40 $mailerMock,<br />

41 $this->getResponseMock(),<br />

42 $dispatcherMock<br />

43 );<br />

44 }<br />

45<br />

46 public function testStore()<br />

47 {<br />

48 $validatorMock = $this->getValidatorMock();<br />

49<br />

50 $validatorMock<br />

51 ->shouldReceive("passes")<br />

52 ->atLeast()<br />

53 ->once()<br />

54 ->with("store")<br />

55 ->andReturn(true);<br />

56<br />

57 $responseMock = $this->getResponseMock();<br />

58<br />

59 $responseMock<br />

60 ->shouldReceive("route")<br />

61 ->atLeast()<br />

62 ->once()<br />

63 ->with("posts.index")<br />

64 ->andReturn($responseMock);<br />

65<br />

66 $responseMock

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

Saved successfully!

Ooh no, something went wrong!