0

I've just started to build an API & Some web app features, using Behat to test scenarios in a BDD fashion.

All is going well, I'm testing the API with a Rest Context and Web App bits with Mink.

However, I've reached a bit of a stumbling block in the automated tests...

I've created an API endpoint for a "Forgot Password" feature, which does the usual random hash/token effort, then emails a link to /reset-password/token

However, in order to automate testing of this URL using Mink I'd need to know the hash of the test user (created earlier in the test suite). Because it's random and will change every time a user requests a password reset, I'm a little stumped as to how I can test this!

Rich
  • 553
  • 1
  • 10
  • 20

1 Answers1

2

Simple: don't be shy to lookup the last (or based on any other criteria) row in your password reset tokens table to get the last generated hash.

If you are new to subject it might sound a little strange that with Behat / Mink you need to do things like that, but thats a totally normal practice to have shortcuts or workarounds like that.

Ian Bytchek
  • 8,804
  • 6
  • 46
  • 72
  • 1
    I'm very new to the subject! Ha. Got it working a treat now - added a custom step to my context to get the hash and call the page. Thanks for the reassurance :) – Rich Sep 18 '14 at 15:00