@@ -122,6 +122,43 @@ public function testAfterFiltersAreExecutedWhenUsingCallbackFilters()
122122 unset($ _SERVER ['__controller.after ' ]);
123123 }
124124
125+
126+ /**
127+ * @expectedException Symfony\Component\HttpKernel\Exception\NotFoundHttpException
128+ */
129+ public function testMissingMethod ()
130+ {
131+ $ controller = new BasicControllerStub ;
132+ $ container = new Illuminate \Container \Container ;
133+ $ container ['filter.parser ' ] = $ container ->share (function () { return m::mock ('StdClass ' ); });
134+ $ container ['filter.parser ' ]->shouldReceive ('parse ' )->andReturn (array ());
135+ $ router = m::mock ('Illuminate\Routing\Router ' );
136+ $ router ->shouldReceive ('getRequest ' )->andReturn (m::mock ('Symfony\Component\HttpFoundation\Request ' ));
137+ $ router ->shouldReceive ('getCurrentRoute ' )->andReturn (m::mock ('Illuminate\Routing\Route ' ));
138+ $ router ->shouldReceive ('prepare ' )->never ()->andReturnUsing (function ($ response , $ request ) { return new Response ($ response ); });
139+
140+ // Call a method that doesn't exists.
141+ $ controller ->callAction ($ container , $ router , 'thisMethodDoesntExists ' , array ('foo ' ));
142+ }
143+
144+
145+ public function testMissingMethodReplacement ()
146+ {
147+ $ controller = new MissingMethodControllerStub ;
148+ $ container = new Illuminate \Container \Container ;
149+ $ container ['filter.parser ' ] = $ container ->share (function () { return m::mock ('StdClass ' ); });
150+ $ container ['filter.parser ' ]->shouldReceive ('parse ' )->andReturn (array ());
151+ $ router = m::mock ('Illuminate\Routing\Router ' );
152+ $ router ->shouldReceive ('getRequest ' )->andReturn (m::mock ('Symfony\Component\HttpFoundation\Request ' ));
153+ $ router ->shouldReceive ('getCurrentRoute ' )->andReturn (m::mock ('Illuminate\Routing\Route ' ));
154+ $ router ->shouldReceive ('prepare ' )->once ()->andReturnUsing (function ($ response , $ request ) { return new Response ($ response ); });
155+
156+ // Call a method that doesn't exists.
157+ $ response = $ controller ->callAction ($ container , $ router , 'thisMethodDoesntExists ' , array ('foo ' ));
158+ $ this ->assertEquals ('Missing method! ' , $ response ->getContent ());
159+ }
160+
161+
125162}
126163
127164class BasicControllerStub extends Illuminate \Routing \Controllers \Controller {
@@ -140,4 +177,11 @@ protected function setupLayout()
140177 {
141178 $ this ->layout = 'Layout ' ;
142179 }
180+ }
181+
182+ class MissingMethodControllerStub extends Illuminate \Routing \Controllers \Controller {
183+ public function missingMethod ($ parameters )
184+ {
185+ return 'Missing method! ' ;
186+ }
143187}
0 commit comments