ResponseFunctionalTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. $result = file_get_contents(sprintf('http://localhost:8054/%s.php', $fixture));
  42. $this->assertStringMatchesFormatFile(__DIR__.sprintf('/Fixtures/response-functional/%s.expected', $fixture), $result);
  43. }
  44. public function provideCookie()
  45. {
  46. foreach (glob(__DIR__.'/Fixtures/response-functional/*.php') as $file) {
  47. yield [pathinfo($file, PATHINFO_FILENAME)];
  48. }
  49. }
  50. }