Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I test this locally with an automated test? #18

Closed
bkuhl opened this issue May 23, 2015 · 3 comments
Closed

How do I test this locally with an automated test? #18

bkuhl opened this issue May 23, 2015 · 3 comments

Comments

@bkuhl
Copy link

bkuhl commented May 23, 2015

Is there a way to test this locally via acceptance tests? With a standard captcha I might be able to have a specific passcode in local that will by pass the actual captcha check but can be used as an assertion that the captcha field is visible on the page, thus testing the 3rd party integration locally. Is there any kind of mechanism for building an acceptance test to ensure this works as I'd expect?

@bkuhl bkuhl changed the title How do I test this locally? How do I test this locally with an automated test? May 23, 2015
@splatEric
Copy link
Contributor

I had the same question, and came up with the following approach which seems to work quite well

  1. Setup NoCaptcha facade in config/app.conf
'NoCaptcha' => 'Anhskohbo\NoCaptcha\Facades\NoCaptcha'
  1. In the test you are writing, you can then mock the facade behaviour:
// prevent validation error on captcha
NoCaptcha::shouldReceive('verifyResponse')
    ->once()
    ->andReturn(true);
// provide hidden input for your 'required' validation
NoCaptcha::shouldReceive('display')
    ->zeroOrMoreTimes()
    ->andReturn('<input type="hidden" name="g-recaptcha-response" value="1" />');

You can then fill out the remainder of the form.

@LaurentEsc
Copy link

I think this should be added to the documentation. I'll make a PR if I find some time.

@josewilsoncc
Copy link

👍 I think this should be added to the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants