LoginCept.php 932 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. use tests\codeception\_pages\LoginPage;
  3. $I = new AcceptanceTester($scenario);
  4. $I->wantTo('ensure that login works');
  5. $loginPage = LoginPage::openBy($I);
  6. $I->see('Login', 'h1');
  7. $I->amGoingTo('try to login with empty credentials');
  8. $loginPage->login('', '');
  9. if (method_exists($I, 'wait')) {
  10. $I->wait(3); // only for selenium
  11. }
  12. $I->expectTo('see validations errors');
  13. $I->see('Username cannot be blank.');
  14. $I->see('Password cannot be blank.');
  15. $I->amGoingTo('try to login with wrong credentials');
  16. $loginPage->login('admin', 'wrong');
  17. if (method_exists($I, 'wait')) {
  18. $I->wait(3); // only for selenium
  19. }
  20. $I->expectTo('see validations errors');
  21. $I->see('Incorrect username or password.');
  22. $I->amGoingTo('try to login with correct credentials');
  23. $loginPage->login('admin', 'admin');
  24. if (method_exists($I, 'wait')) {
  25. $I->wait(3); // only for selenium
  26. }
  27. $I->expectTo('see user info');
  28. $I->see('Logout (admin)');