LoginCept.php 975 B

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