SignupCest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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.', '.help-block');
  30. $I->dontSee('Password cannot be blank.', '.help-block');
  31. $I->see('Email is not a valid email address.', '.help-block');
  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. ]);
  44. $I->see('Logout (tester)', 'form button[type=submit]');
  45. }
  46. }