03.12.2015 Views

laravel4cookbook

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Controller Testing 373<br />

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

110<br />

111 $responseMock<br />

112 ->shouldReceive("back")<br />

113 ->atLeast()<br />

114 ->once()<br />

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

116<br />

117 $responseMock<br />

118 ->shouldReceive("withErrors")<br />

119 ->atLeast()<br />

120 ->once()<br />

121 ->with(["foo"])<br />

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

123<br />

124 $responseMock<br />

125 ->shouldReceive("withInput")<br />

126 ->atLeast()<br />

127 ->once()<br />

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

129<br />

130 $postController = new PostController(<br />

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

132 $validatorMock,<br />

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

134 $responseMock,<br />

135 $this->getDispatcherMock()<br />

136 );<br />

137<br />

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

139 }<br />

140<br />

141 protected function getRepositoryMock()<br />

142 {<br />

143 return Mockery::mock("Formativ\PostRepositoryInterface")<br />

144 ->makePartial();<br />

145 }<br />

146<br />

147 protected function getValidatorMock()<br />

148 {<br />

149 return Mockery::mock("Formativ\PostValidatorInterface")<br />

150 ->makePartial();

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

Saved successfully!

Ooh no, something went wrong!