|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Copyright © OXID eSales AG. All rights reserved. |
| 5 | + * See LICENSE file for license details. |
| 6 | + */ |
| 7 | + |
| 8 | +declare(strict_types=1); |
| 9 | + |
| 10 | +namespace OxidEsales\Graphql\Base\Tests\Codeception\Config; |
| 11 | + |
| 12 | +use OxidEsales\Codeception\Module\Database\DatabaseDefaultsFileGenerator; |
| 13 | +use OxidEsales\Facts\Config\ConfigFile; |
| 14 | +use OxidEsales\Facts\Facts; |
| 15 | +use Symfony\Component\Filesystem\Path; |
| 16 | + |
| 17 | +if ($shopRootPath = getenv('SHOP_ROOT_PATH')) { |
| 18 | + require_once(Path::join($shopRootPath, 'source', 'bootstrap.php')); |
| 19 | +} |
| 20 | + |
| 21 | +class CodeceptionParametersProvider { |
| 22 | + |
| 23 | + public function getParameters(): array |
| 24 | + { |
| 25 | + $facts = new Facts(); |
| 26 | + $php = (getenv('PHPBIN')) ?: 'php'; |
| 27 | + |
| 28 | + return [ |
| 29 | + 'SHOP_URL' => $facts->getShopUrl(), |
| 30 | + 'SHOP_SOURCE_PATH' => $facts->getSourcePath(), |
| 31 | + 'VENDOR_PATH' => $facts->getVendorPath(), |
| 32 | + 'DB_NAME' => $facts->getDatabaseName(), |
| 33 | + 'DB_USERNAME' => $facts->getDatabaseUserName(), |
| 34 | + 'DB_PASSWORD' => $facts->getDatabasePassword(), |
| 35 | + 'DB_HOST' => $facts->getDatabaseHost(), |
| 36 | + 'DB_PORT' => $facts->getDatabasePort(), |
| 37 | + 'MODULE_DUMP_PATH' => $this->getModuleTestDataDumpFilePath(), |
| 38 | + 'MYSQL_CONFIG_PATH' => $this->getMysqlConfigPath(), |
| 39 | + 'PHP_BIN' => $php, |
| 40 | + ]; |
| 41 | + } |
| 42 | + |
| 43 | + private function getModuleTestDataDumpFilePath() |
| 44 | + { |
| 45 | + return Path::join(__DIR__, '..', 'Support', 'Data', 'dump.sql'); |
| 46 | + } |
| 47 | + |
| 48 | + private function getMysqlConfigPath() |
| 49 | + { |
| 50 | + $facts = new Facts(); |
| 51 | + $configFile = new ConfigFile($facts->getSourcePath() . '/config.inc.php'); |
| 52 | + |
| 53 | + $generator = new DatabaseDefaultsFileGenerator($configFile); |
| 54 | + |
| 55 | + return $generator->generate(); |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | + |
0 commit comments