Environment.php 986 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Bootstrap of the HTTP environment
  8. */
  9. namespace Magento\TestFramework\Bootstrap;
  10. class Environment
  11. {
  12. /**
  13. * Emulate properties typical to an HTTP request
  14. *
  15. * @param array $serverVariables
  16. */
  17. public function emulateHttpRequest(array &$serverVariables)
  18. {
  19. // emulate HTTP request
  20. $serverVariables['HTTP_HOST'] = 'localhost';
  21. // emulate entry point to ensure that tests generate invariant URLs
  22. $serverVariables['SCRIPT_FILENAME'] = 'index.php';
  23. }
  24. /**
  25. * Emulate already started PHP session
  26. *
  27. * @param array|null $sessionVariables
  28. */
  29. public function emulateSession(&$sessionVariables)
  30. {
  31. // prevent session_start, because it may rely on cookies
  32. $sessionVariables = [];
  33. // application relies on a non-empty session ID
  34. session_id(uniqid());
  35. }
  36. }