WebApiApplication.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\TestFramework;
  7. /**
  8. * Provides access to the application for the tests
  9. *
  10. * Allows installation and uninstallation
  11. */
  12. class WebApiApplication extends Application
  13. {
  14. /**
  15. * {@inheritdoc}
  16. */
  17. public function run()
  18. {
  19. throw new \Exception(
  20. "Can't start application: purpose of Web API Application is to use classes and models from the application"
  21. . " and don't run it"
  22. );
  23. }
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function install($cleanup)
  28. {
  29. if ($cleanup) {
  30. $this->cleanup();
  31. }
  32. $installOptions = $this->getInstallConfig();
  33. /* Install application */
  34. if ($installOptions) {
  35. $installCmd = 'php -f ' . BP . '/bin/magento setup:install -vvv';
  36. $installArgs = [];
  37. foreach ($installOptions as $optionName => $optionValue) {
  38. if (is_bool($optionValue)) {
  39. if (true === $optionValue) {
  40. $installCmd .= " --$optionName";
  41. }
  42. continue;
  43. }
  44. if (!empty($optionValue)) {
  45. $installCmd .= " --$optionName=%s";
  46. $installArgs[] = $optionValue;
  47. }
  48. }
  49. $this->_shell->execute($installCmd, $installArgs);
  50. }
  51. }
  52. /**
  53. * Use the application as is
  54. *
  55. * {@inheritdoc}
  56. */
  57. protected function getCustomDirs()
  58. {
  59. return [];
  60. }
  61. }