How to test response of successful form submit in presenter test with nette tester

I want to test the sign in presenter action with form submit and correct response in redirect. E.g. I want to test that after correct login, user is redirected somewhere and flash message with text “login successful” is displayed.

In all the examples the only way to test correct form behavior is to test that I get RedirectResponse (see below). Isn’t that too little? How to do the test I describe? Is it even possible?

function testSignUpSuccess()
    $post = [
        'identity' => '',
        'password' => 'superSecret123',

    $pt = $this->getPresenterTester()

    $response = $pt->run();

    Assert::true($response instanceof NetteApplicationResponsesRedirectResponse);

    //TODO test that flashMessage: 'login successful' is displayed on final page

Note: This example uses PresenterTester tool to get the response but the important part is about working with that response so it doesn’t matter whether you get it by native means or by this tool.

Source: forms

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.