ParametersHolder.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\TestFramework\Deploy;
  7. use Magento\Framework\App\Filesystem\DirectoryList;
  8. use Magento\Framework\Shell;
  9. use Magento\Setup\Console\Command\InstallCommand;
  10. /**
  11. * The purpose of this class is enable/disable module and upgrade commands execution.
  12. */
  13. class ParametersHolder
  14. {
  15. /**
  16. * Initialize params.
  17. *
  18. * @var array
  19. */
  20. private $initParams;
  21. /**
  22. * Return application initialization parameters.
  23. *
  24. * @return array
  25. */
  26. public function getInitParams()
  27. {
  28. if (!isset($this->initParams)) {
  29. $customDirs = $this->getCustomDirs();
  30. $initParams = [
  31. \Magento\Framework\App\Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS => $customDirs,
  32. ];
  33. $this->initParams = ['magento-init-params' => urldecode(http_build_query($initParams))];
  34. }
  35. return $this->initParams;
  36. }
  37. /**
  38. * Include data from config file and convert it to db format:
  39. * -db-name
  40. * -db-user-name
  41. * -db-password
  42. * -db-host
  43. *
  44. * @param string $resource can be default, checkout, sales
  45. * @return array
  46. */
  47. public function getDbData($resource)
  48. {
  49. $dbData = include TESTS_INSTALLATION_DB_CONFIG_FILE;
  50. return $dbData[$resource];
  51. }
  52. /**
  53. * Get customized directory paths.
  54. *
  55. * @return array
  56. */
  57. private function getCustomDirs()
  58. {
  59. $installDir = TESTS_TEMP_DIR;
  60. $path = DirectoryList::PATH;
  61. $var = "{$installDir}/var";
  62. $customDirs = [
  63. DirectoryList::CONFIG => [$path => "{$installDir}/etc"],
  64. DirectoryList::VAR_DIR => [$path => $var],
  65. ];
  66. return $customDirs;
  67. }
  68. }