LoginCept.php 853 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. use 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. $I->expectTo('see validations errors');
  10. $I->see('Username cannot be blank.');
  11. $I->see('Password cannot be blank.');
  12. $I->amGoingTo('try to login with wrong credentials');
  13. $loginPage->login('admin', 'wrong');
  14. if (method_exists($I, 'wait')) {
  15. $I->wait(3); // only for selenium
  16. }
  17. $I->expectTo('see validations errors');
  18. $I->see('Incorrect username or password.');
  19. $I->amGoingTo('try to login with correct credentials');
  20. $loginPage->login('admin', 'admin');
  21. if (method_exists($I, 'wait')) {
  22. $I->wait(3); // only for selenium
  23. }
  24. $I->expectTo('see user info');
  25. $I->see('Logout (admin)');