Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

91 Zeilen
2.5KB

  1. <?php
  2. namespace tests\codeception\frontend\functional;
  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. *
  34. * @param \codeception_frontend\FunctionalTester $I
  35. * @param \Codeception\Scenario $scenario
  36. */
  37. public function testUserSignup($I, $scenario)
  38. {
  39. $I->wantTo('ensure that signup works');
  40. $signupPage = SignupPage::openBy($I);
  41. $I->see('Signup', 'h1');
  42. $I->see('Please fill out the following fields to signup:');
  43. $I->amGoingTo('submit signup form with no data');
  44. $signupPage->submit([]);
  45. $I->expectTo('see validation errors');
  46. $I->see('Username cannot be blank.', '.help-block');
  47. $I->see('Email cannot be blank.', '.help-block');
  48. $I->see('Password cannot be blank.', '.help-block');
  49. $I->amGoingTo('submit signup form with not correct email');
  50. $signupPage->submit([
  51. 'username' => 'tester',
  52. 'email' => 'tester.email',
  53. 'password' => 'tester_password',
  54. ]);
  55. $I->expectTo('see that email address is wrong');
  56. $I->dontSee('Username cannot be blank.', '.help-block');
  57. $I->dontSee('Password cannot be blank.', '.help-block');
  58. $I->see('Email is not a valid email address.', '.help-block');
  59. $I->amGoingTo('submit signup form with correct email');
  60. $signupPage->submit([
  61. 'username' => 'tester',
  62. 'email' => 'tester.email@example.com',
  63. 'password' => 'tester_password',
  64. ]);
  65. $I->expectTo('see that user is created');
  66. $I->seeRecord('common\models\User', [
  67. 'username' => 'tester',
  68. 'email' => 'tester.email@example.com',
  69. ]);
  70. $I->expectTo('see that user logged in');
  71. $I->seeLink('Logout (tester)');
  72. }
  73. }