FirewallEntryPointTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
  11. use Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\Security\EntryPointStub;
  12. class FirewallEntryPointTest extends WebTestCase
  13. {
  14. public function testItUsesTheConfiguredEntryPointWhenUsingUnknownCredentials()
  15. {
  16. $client = $this->createClient(array('test_case' => 'FirewallEntryPoint'));
  17. $client->request('GET', '/secure/resource', array(), array(), array(
  18. 'PHP_AUTH_USER' => 'unknown',
  19. 'PHP_AUTH_PW' => 'credentials',
  20. ));
  21. $this->assertEquals(
  22. EntryPointStub::RESPONSE_TEXT,
  23. $client->getResponse()->getContent(),
  24. "Custom entry point wasn't started"
  25. );
  26. }
  27. public function testItUsesTheConfiguredEntryPointFromTheExceptionListenerWithFormLoginAndNoCredentials()
  28. {
  29. $client = $this->createClient(array('test_case' => 'FirewallEntryPoint', 'root_config' => 'config_form_login.yml'));
  30. $client->request('GET', '/secure/resource');
  31. $this->assertEquals(
  32. EntryPointStub::RESPONSE_TEXT,
  33. $client->getResponse()->getContent(),
  34. "Custom entry point wasn't started"
  35. );
  36. }
  37. }