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

67 ->shouldReceive("with")<br />

68 ->atLeast()<br />

69 ->once()<br />

70 ->with("success", true);<br />

71<br />

72 $dispatcherMock = $this->getDispatcherMock();<br />

73<br />

74 $dispatcherMock<br />

75 ->shouldReceive("fire")<br />

76 ->atLeast()<br />

77 ->once()<br />

78 ->with("post.store");<br />

79<br />

80 $postController = new PostController(<br />

81 $this->getRepositoryMock(),<br />

82 $validatorMock,<br />

83 $this->getMailerMock(),<br />

84 $responseMock,<br />

85 $dispatcherMock<br />

86 );<br />

87<br />

88 $postController->store();<br />

89 }<br />

90<br />

91 public function testStoreFails()<br />

92 {<br />

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

94<br />

95 $validatorMock<br />

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

97 ->atLeast()<br />

98 ->once()<br />

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

100 ->andReturn(false);<br />

101<br />

102 $validatorMock<br />

103 ->shouldReceive("messages")<br />

104 ->atLeast()<br />

105 ->once()<br />

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

107 ->andReturn(["foo"]);<br />

108

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

Saved successfully!

Ooh no, something went wrong!