2

I'm using Symfony2 with Behat, Mink and the FosUser Bundle. The problem is that the login test always fails (the login works perfectly in development).

 Scenario: A user can login
    Given I am on "http://localhost:8888/myapp/web/login"
    And fill in "username" with "[email protected]"
    And fill in "password" with "pass"
    And press "login"
    Then I should see "Logout"

The test fails with The text "Logout" was not found anywhere in the text of the current page. Any idea on what's missing or how I could debug the problem?

I can test non-authenticated pages with Behat/Mink.

[Update]

The config_test is as follows (just the relevant bits):

## Security Configuration
security:
encoders:
    Symfony\Component\Security\Core\User\User: plaintext

providers:
    main:
        users:
            [email protected]: { password: senha, roles: ROLE_ADMIN }

firewalls:
    secured_area:
        pattern:    ^/
        http_basic: true
        logout:     true
        security: true
        anonymous: true
2
  • Also tried with other testing frameworks, standalone zombie.js and Story.php and they both fail so maybe it's something with the some cookie or token missing which causes the test to fail if not running in a browser?.. Commented Dec 30, 2011 at 3:44
  • add mink config (from /app/config/config_test.yml) please Commented Dec 30, 2011 at 10:41

2 Answers 2

2

"print last response" step should help you finding out what went wrong:

Scenario: A user can login
  Given I am on "http://localhost:8888/myapp/web/login"
    And fill in "username" with "[email protected]"
    And fill in "password" with "pass"
    And press "login"
    And print last response
   Then I should see "Logout"
Sign up to request clarification or add additional context in comments.

Comments

0

It doesn't work probably because the user's password isn't pass, it's senha.

2 Comments

That's a typo, senha equals pass in portuguese. i simply changed it to english when i posted the first time and didn't change in the second time. In my test it's senha as it's supposed to be. Any idea what's wrong? Can you test authenticated pages using behat in symfony?
Which driver are you using with Mink?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.