State1.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Mtf\App\State;
  7. use Magento\Mtf\ObjectManager;
  8. use Magento\Mtf\Util\Command\Cli;
  9. use Magento\Mtf\Util\Protocol\CurlInterface;
  10. use Magento\Mtf\Util\Protocol\CurlTransport;
  11. /**
  12. * Example Application State class.
  13. */
  14. class State1 extends AbstractState
  15. {
  16. /**
  17. * Object Manager.
  18. *
  19. * @var ObjectManager
  20. */
  21. protected $objectManager;
  22. /**
  23. * Data for configuration state.
  24. *
  25. * @var string
  26. */
  27. protected $config ='admin_session_lifetime_1_hour, wysiwyg_disabled, admin_account_sharing_enable';
  28. /**
  29. * HTTP CURL Adapter.
  30. *
  31. * @var CurlTransport
  32. */
  33. private $curlTransport;
  34. /**
  35. * @param ObjectManager $objectManager
  36. * @param CurlTransport $curlTransport
  37. * @param array $arguments
  38. */
  39. public function __construct(
  40. ObjectManager $objectManager,
  41. CurlTransport $curlTransport,
  42. array $arguments = []
  43. ) {
  44. parent::__construct($objectManager, $arguments);
  45. $this->objectManager = $objectManager;
  46. $this->curlTransport = $curlTransport;
  47. }
  48. /**
  49. * Apply set up configuration profile.
  50. *
  51. * @return void
  52. * @throws \Exception
  53. */
  54. public function apply()
  55. {
  56. parent::apply();
  57. $this->curlTransport->write($_ENV['app_frontend_url'], [], CurlInterface::GET);
  58. $response = $this->curlTransport->read();
  59. if (strpos($response, 'Home Page') !== false) {
  60. $this->objectManager->create(
  61. \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
  62. ['configData' => $this->config]
  63. )->run();
  64. }
  65. /** @var Cli $cli */
  66. $cli = $this->objectManager->create(Cli::class);
  67. $cli->execute('setup:config:set', ['--enable-debug-logging=true']);
  68. }
  69. /**
  70. * Get name of the Application State Profile.
  71. *
  72. * @return string
  73. */
  74. public function getName()
  75. {
  76. return 'Configuration Profile #1';
  77. }
  78. }