Commit c38aa97f authored by Nguyen Van Anh's avatar Nguyen Van Anh

Merge pull request #28 from splatEric/master

+ added documentation for working with Laravel testing.
parents 753d49a6 3258005b
...@@ -58,6 +58,31 @@ $validate = Validator::make(Input::all(), [ ...@@ -58,6 +58,31 @@ $validate = Validator::make(Input::all(), [
``` ```
### Testing
When using the (Laravel Testing functionality)[http://laravel.com/docs/5.1/testing], you will need to mock out the response for the captcha form element. To do this:
1) Setup NoCaptcha facade in config/app.conf
```php
'NoCaptcha' => 'Anhskohbo\NoCaptcha\Facades\NoCaptcha'
```
2) For any form tests involving the captcha, you can then mock the facade behaviour:
```php
// 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 test the remainder of your form as normal.
## Without Laravel ## Without Laravel
Checkout example below: Checkout example below:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment