public function tryRegister(FunctionalTester $I){
//arrange
$I->disableEvents();
$user = $I->factory()->instance(User::class);
$new_password = str_random(10);
// 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" alue="1" />');
//act
$I->amOnPage(route('auth.register'));
$I->fillField("username",$user->username);
$I->fillField("name",$user->name);
$I->fillField("email",$user->email);
$I->fillField("password",$new_password);
$I->fillField("password_confirmation",$new_password);
$I->click('Register');
$I->seeCurrentRouteIs('auth.login');
//$I->seeEventTriggered(UserRegistered::class);
//assert
$registered_user = \UserRepo::findByField('email',$user->email)->first();
$I->assertFalse(\Auth::check());
$I->assertTrue($user->name == $registered_user->name);
$I->assertTrue($user->username == $registered_user->username);
$I->assertTrue($user->email == $registered_user->email);
$I->assertTrue(\Hash::check($new_password,$registered_user->password));
}
I have this functional test I want to run but, it's failing because of the recapcha embedded into the page. My mocked objects don't seem to have any affect. Am I going about this in the wrong fashion?
Looks like you have to use haveBinding