ResponseFunctionalTest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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\Component\HttpFoundation\Tests;
  11. use PHPUnit\Framework\TestCase;
  12. /**
  13. * @requires PHP 7.0
  14. */
  15. class ResponseFunctionalTest extends TestCase
  16. {
  17. private static $server;
  18. public static function setUpBeforeClass()
  19. {
  20. $spec = [
  21. 1 => ['file', '/dev/null', 'w'],
  22. 2 => ['file', '/dev/null', 'w'],
  23. ];
  24. if (!self::$server = @proc_open('exec php -S localhost:8054', $spec, $pipes, __DIR__.'/Fixtures/response-functional')) {
  25. self::markTestSkipped('PHP server unable to start.');
  26. }
  27. sleep(1);
  28. }
  29. public static function tearDownAfterClass()
  30. {
  31. if (self::$server) {
  32. proc_terminate(self::$server);
  33. proc_close(self::$server);
  34. }
  35. }
  36. /**
  37. * @dataProvider provideCookie
  38. */
  39. public function testCookie($fixture)
  40. {
  41. if (\PHP_VERSION_ID >= 80000 && 'cookie_max_age' === $fixture) {
  42. $this->markTestSkipped('This fixture produces a fatal error on PHP 8.');
  43. }
  44. $result = file_get_contents(sprintf('http://localhost:8054/%s.php', $fixture));
  45. $this->assertStringMatchesFormatFile(__DIR__.sprintf('/Fixtures/response-functional/%s.expected', $fixture), $result);
  46. }
  47. public function provideCookie()
  48. {
  49. foreach (glob(__DIR__.'/Fixtures/response-functional/*.php') as $file) {
  50. yield [pathinfo($file, \PATHINFO_FILENAME)];
  51. }
  52. }
  53. }