This test behaves correctly when Xdebug is ON, and incorrectly when its OFF.
However, the second problem with not seeing the record occurs regardless of Xdebug status.
Please read the comments in the code.
If I remove the attributes of ‘mobile_verification_status’ and ‘status’ from the problematic seeRecord, it works. The record is saved in the test database correctly with correct status and mobile_verification_status. I checked it a hundred times.
Any idea?
public function signupAndVerifyByMobileSuccessfully(AcceptanceTester $I)
{
$I->fillField("SignupForm[mobile]", '09122499514');
$I->fillField("SignupForm[email]", 'nima.naraghi4@gmail.com');
$I->fillField("SignupForm[password]", 'tester_password');
$I->fillField("SignupForm[password_repeat]", 'tester_password');
$I->click('Signup');
$I->wait(3);
$I->seeRecord('common\models\User', [
'mobile' => '+98 912 249 9514',
'email' => 'nima.naraghi4@gmail.com',
'status' => \common\models\User::STATUS_INACTIVE,
'email_verification_status' => false,
'mobile_verification_status' => false,
]);
$I->wait(3);
$I->seeInCurrentUrl('verify-mobile');
$I->wait(7);
$I->amGoingTo('Get the generated mobile verification code');
$user = $I->grabRecord('\common\models\User', [
'mobile' => '+98 912 249 9514',
'status' => \common\models\User::STATUS_INACTIVE
]);
$userVerificationCode = $user->mobile_verification_code;
if(empty($userVerificationCode)){
throw new \Exception('user verification code is empty'); // **It doesn't happen only when the Xdebug is ON very much like Double-slit experiment in the quantum mechanics.**
}
$I->fillField('MobileKavenegarVerificationForm[mobileVerificationCode]', $userVerificationCode);
$I->wait(3);
$I->click('Submit');
$I->wait(5);
$I->seeRecord('\common\models\User', [ // **This does not see the record whilst it exists.**
'id' => $user->id,
'mobile_verification_status' => \common\models\User::MOBILE_VERIFICATION_STATUS_VERIFIED,
'status' => User::STATUS_ACTIVE
]);
$I->see("Your mobile was successfully verified.");
$I->see("Congratulations! Your account is now active.");
}