RetryAuthenticationEntryPointTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Symfony\Tests\Component\Security\Http\EntryPoint;
  3. use Symfony\Component\Security\Http\EntryPoint\RetryAuthenticationEntryPoint;
  4. use Symfony\Component\HttpFoundation\Request;
  5. class RetryAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase
  6. {
  7. /**
  8. * @dataProvider dataForStart
  9. */
  10. public function testStart($httpPort, $httpsPort, $request, $expectedUrl)
  11. {
  12. $entryPoint = new RetryAuthenticationEntryPoint($httpPort, $httpsPort);
  13. $response = $entryPoint->start($request);
  14. $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response);
  15. $this->assertEquals($expectedUrl, $response->headers->get('Location'));
  16. }
  17. public function dataForStart()
  18. {
  19. return array(
  20. array(
  21. 80,
  22. 443,
  23. Request::create('http://localhost/foo/bar?baz=bat'),
  24. 'https://localhost/foo/bar?baz=bat'
  25. ),
  26. array(
  27. 80,
  28. 443,
  29. Request::create('https://localhost/foo/bar?baz=bat'),
  30. 'http://localhost/foo/bar?baz=bat'
  31. ),
  32. array(
  33. 80,
  34. 123,
  35. Request::create('http://localhost/foo/bar?baz=bat'),
  36. 'https://localhost:123/foo/bar?baz=bat'
  37. ),
  38. array(
  39. 8080,
  40. 443,
  41. Request::create('https://localhost/foo/bar?baz=bat'),
  42. 'http://localhost:8080/foo/bar?baz=bat'
  43. )
  44. );
  45. }
  46. }