{
    }
    public function barAction()
    {
        return self::ACTION_FAILURE;
    }
    public function myBar()
    {
    }
}
// @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);
Ejemplo n.º 2
0
 function test_respond_to_forced_to_xml()
 {
     $dispatcher = new Trails_Dispatcher('var://app', 'trails_uri', 'default');
     $controller = new FooController($dispatcher);
     $response = $controller->perform('index.xml');
     $this->assertFalse($controller->respond_to('html'));
     $this->assertTrue($controller->respond_to('xml'), "Controller does not respond to xml but to {$controller->format}");
 }