IndexControllerTest.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Muzich\CoreBundle\Tests\Controller;
  3. use Muzich\CoreBundle\lib\FunctionalTest;
  4. class IndexControllerTest extends FunctionalTest
  5. {
  6. public function testIdentification()
  7. {
  8. /**
  9. * Test de l'identification de paul
  10. */
  11. $this->client = self::createClient();
  12. $this->crawler = $this->client->request('GET', $this->generateUrl('index'));
  13. $this->isResponseSuccess();
  14. $this->assertEquals('anon.', $this->getUser());
  15. $this->exist('div.login');
  16. $this->exist('form[action="'.($url = $this->generateUrl('fos_user_security_check')).'"]');
  17. $this->exist('form[action="'.$url.'"] input[id="username"]');
  18. $this->exist('form[action="'.$url.'"] input[id="password"]');
  19. $this->exist('form[action="'.$url.'"] input[id="remember_me"]');
  20. $this->exist('form[action="'.$url.'"] input[type="submit"]');
  21. $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
  22. $form['_username'] = 'paul';
  23. $form['_password'] = 'toor';
  24. $form['_remember_me'] = true;
  25. $this->submit($form);
  26. $this->isResponseRedirection();
  27. $this->followRedirection();
  28. $this->isResponseSuccess();
  29. $user = $this->getUser();
  30. $this->assertEquals('paul', $user->getUsername());
  31. }
  32. }