You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 satır
2.3KB

  1. <?php
  2. namespace tests\codeception\frontend\acceptance;
  3. use tests\codeception\frontend\_pages\SignupPage;
  4. use common\models\User;
  5. class SignupCest
  6. {
  7. /**
  8. * This method is called before each cest class test method
  9. * @param \Codeception\Event\TestEvent $event
  10. */
  11. public function _before($event)
  12. {
  13. }
  14. /**
  15. * This method is called after each cest class test method, even if test failed.
  16. * @param \Codeception\Event\TestEvent $event
  17. */
  18. public function _after($event)
  19. {
  20. User::deleteAll([
  21. 'email' => 'tester.email@example.com',
  22. 'username' => 'tester',
  23. ]);
  24. }
  25. /**
  26. * This method is called when test fails.
  27. * @param \Codeception\Event\FailEvent $event
  28. */
  29. public function _fail($event)
  30. {
  31. }
  32. /**
  33. * @param \codeception_frontend\AcceptanceTester $I
  34. * @param \Codeception\Scenario $scenario
  35. */
  36. public function testUserSignup($I, $scenario)
  37. {
  38. $I->wantTo('ensure that signup works');
  39. $signupPage = SignupPage::openBy($I);
  40. $I->see('Signup', 'h1');
  41. $I->see('Please fill out the following fields to signup:');
  42. $I->amGoingTo('submit signup form with no data');
  43. $signupPage->submit([]);
  44. $I->expectTo('see validation errors');
  45. $I->see('Username cannot be blank.', '.help-block');
  46. $I->see('Email cannot be blank.', '.help-block');
  47. $I->see('Password cannot be blank.', '.help-block');
  48. $I->amGoingTo('submit signup form with not correct email');
  49. $signupPage->submit([
  50. 'username' => 'tester',
  51. 'email' => 'tester.email',
  52. 'password' => 'tester_password',
  53. ]);
  54. $I->expectTo('see that email address is wrong');
  55. $I->dontSee('Username cannot be blank.', '.help-block');
  56. $I->dontSee('Password cannot be blank.', '.help-block');
  57. $I->see('Email is not a valid email address.', '.help-block');
  58. $I->amGoingTo('submit signup form with correct email');
  59. $signupPage->submit([
  60. 'username' => 'tester',
  61. 'email' => 'tester.email@example.com',
  62. 'password' => 'tester_password',
  63. ]);
  64. $I->expectTo('see that user logged in');
  65. $I->seeLink('Logout (tester)');
  66. }
  67. }