2016-04-23 133 views
0

我必須測試我的註冊表單,但我不知道如何測試reCaptcha字段。laravel 5單元測試captcha

我得到錯誤:

HomeTest::testNewUserRegistration InvalidArgumentException: Nothing matched the filter [captcha] CSS query provided for [ http://localhost/auth/register] .

這裏是我目前的測試:

public function testNewUserRegistration() 
    { 
     $faker = Faker\Factory::create(); 
     $this->visit(route('auth.register')) 
      ->type($faker->firstNameMale, 'firstname') 
      ->type($faker->lastName, 'lastname') 
      ->type($faker->userName, 'username') 
      ->type($faker->email, 'email') 
      ->attach($faker->imageUrl(), 'avatar') 
      ->type($faker->password, 'password') 
      ->type($faker->password, 'password_confirmation') 
      ->check('terms') 

      ->check('captcha') 

      ->press('Envoyer') 
      ->seePageIs('/'); 
    } 
在我的形式

我宣佈我的驗證碼,如:

<div class="field {!! $errors->has('g-recaptcha-response') ? 'error' : '' !!}"> 
       {!! app('captcha')->display() !!} 
       {!! $errors->first('g-recaptcha-response', '<span class="ui text" style="color: #bf4d4b">:message</span>') !!} 
      </div> 

回答