Website.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Mtf\Util\Command;
  7. use Magento\Mtf\Util\Protocol\CurlInterface;
  8. use Magento\Mtf\Util\Protocol\CurlTransport;
  9. /**
  10. * Perform Website folder creation for functional tests executions.
  11. */
  12. class Website
  13. {
  14. /**
  15. * Url to website.php.
  16. */
  17. const URL = 'dev/tests/functional/utils/website.php';
  18. /**
  19. * Curl transport protocol.
  20. *
  21. * @var CurlTransport
  22. */
  23. private $transport;
  24. /**
  25. * @constructor
  26. * @param CurlTransport $transport
  27. */
  28. public function __construct(CurlTransport $transport)
  29. {
  30. $this->transport = $transport;
  31. }
  32. /**
  33. * Creates Website folder in root directory.
  34. *
  35. * @param string $websiteCode
  36. * @throws \Exception
  37. */
  38. public function create($websiteCode)
  39. {
  40. $curl = $this->transport;
  41. $curl->addOption(CURLOPT_HEADER, 1);
  42. $curl->write($this->prepareUrl($websiteCode), [], CurlInterface::GET);
  43. $curl->read();
  44. $curl->close();
  45. }
  46. /**
  47. * Prepare url.
  48. *
  49. * @param string $websiteCode
  50. * @return string
  51. */
  52. private function prepareUrl($websiteCode)
  53. {
  54. return $_ENV['app_frontend_url'] . self::URL . '?website_code=' . urlencode($websiteCode);
  55. }
  56. }