SignupCest.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace frontend\tests\functional;
  3. use frontend\tests\FunctionalTester;
  4. class SignupCest
  5. {
  6. protected $formId = '#form-signup';
  7. public function _before(FunctionalTester $I)
  8. {
  9. $I->amOnRoute('site/signup');
  10. }
  11. public function signupWithEmptyFields(FunctionalTester $I)
  12. {
  13. $I->see('Signup', 'h1');
  14. $I->see('Please fill out the following fields to signup:');
  15. $I->submitForm($this->formId, []);
  16. $I->seeValidationError('Username cannot be blank.');
  17. $I->seeValidationError('Email cannot be blank.');
  18. $I->seeValidationError('Password cannot be blank.');
  19. }
  20. public function signupWithWrongEmail(FunctionalTester $I)
  21. {
  22. $I->submitForm(
  23. $this->formId, [
  24. 'SignupForm[username]' => 'tester',
  25. 'SignupForm[email]' => 'ttttt',
  26. 'SignupForm[password]' => 'tester_password',
  27. ]
  28. );
  29. $I->dontSee('Username cannot be blank.', '.invalid-feedback');
  30. $I->dontSee('Password cannot be blank.', '.invalid-feedback');
  31. $I->see('Email is not a valid email address.', '.invalid-feedback');
  32. }
  33. public function signupSuccessfully(FunctionalTester $I)
  34. {
  35. $I->submitForm($this->formId, [
  36. 'SignupForm[username]' => 'tester',
  37. 'SignupForm[email]' => 'tester.email@example.com',
  38. 'SignupForm[password]' => 'tester_password',
  39. ]);
  40. $I->seeRecord('common\models\User', [
  41. 'username' => 'tester',
  42. 'email' => 'tester.email@example.com',
  43. 'status' => \common\models\User::STATUS_INACTIVE
  44. ]);
  45. $I->seeEmailIsSent();
  46. $I->see('Thank you for registration. Please check your inbox for verification email.');
  47. }
  48. }