AuthCest.php 923 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Tests;
  4. use App\Entity\Interfaces\UserRolesInterface;
  5. use App\Tests\FunctionalTester;
  6. class AuthCest
  7. {
  8. /**
  9. * @param FunctionalTester $I
  10. */
  11. public function testForbidden(FunctionalTester $I)
  12. {
  13. $I->amOnPage('/admin');
  14. $I->wantTo('Test redirect to login page');
  15. $I->seePageRedirectsTo('/admin', '/login');
  16. $I->dontSeeInTitle('Администрирование');
  17. }
  18. /**
  19. * @param FunctionalTester $I
  20. */
  21. public function testAuth(FunctionalTester $I)
  22. {
  23. $I->amOnPage('/admin');
  24. $I->wantTo('Test auth');
  25. $I->fillField(['name' => 'email'], 'test@balticrest.ru');
  26. $I->fillField(['name' => 'password'], 'test');
  27. $I->click('div.login_form button');
  28. $I->seeInTitle('Администрирование');
  29. $I->am(UserRolesInterface::ROLE_USER);
  30. }
  31. }