} // @Before $requestMock = $t->mock('Sonata_Request'); $responseMock = $t->mock('Sonata_Response'); $varHolderMock = $t->mock('Sonata_ParameterHolder'); $templateVewMock = $t->mock('Sonata_TemplateView'); $fooController = new FooController($requestMock, $responseMock, $varHolderMock); // @After unset($requestMock); unset($responseMock); unset($varHolderMock); unset($templateVewMock); // @Test: ->dispatch() // @Test: general try { $fooController->dispatch('fail', $templateVewMock); $t->fail('No code should be executed after calling non-existing actions'); } catch (Sonata_Exception_Controller_Action $ex) { $t->pass('An exception is thrown for non-existing actions'); } try { $fooController->dispatch('myBar', $templateVewMock); $t->pass('Existing methods are executed correctly'); } catch (Sonata_Exception_Controller_Action $ex) { $t->fail('No exception should be thrown for existing methods'); } try { $fooController->dispatch('myBaz', $templateVewMock); $t->fail('No code should be executed after calling non-existing methods'); } catch (Sonata_Exception_Controller_Action $ex) { $t->pass('An exception is thrown for non-existing methods');