Skip to content

Commit 238dabf

Browse files
committed
OXDEV-8623 Move codeception parameters into provider class
1 parent bea7a57 commit 238dabf

2 files changed

Lines changed: 61 additions & 39 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+

tests/Codeception/Config/params.php

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,6 @@
77

88
declare(strict_types=1);
99

10-
use OxidEsales\Codeception\Module\Database\DatabaseDefaultsFileGenerator;
11-
use OxidEsales\Facts\Config\ConfigFile;
12-
use OxidEsales\Facts\Facts;
13-
use Symfony\Component\Filesystem\Path;
10+
namespace OxidEsales\Graphql\Base\Tests\Codeception\Config;
1411

15-
if ($shopRootPath = getenv('SHOP_ROOT_PATH')){
16-
require_once(Path::join($shopRootPath, 'source', 'bootstrap.php'));
17-
}
18-
19-
$facts = new Facts();
20-
$php = (getenv('PHPBIN')) ?: 'php';
21-
22-
return [
23-
'SHOP_URL' => $facts->getShopUrl(),
24-
'SHOP_SOURCE_PATH' => $facts->getSourcePath(),
25-
'VENDOR_PATH' => $facts->getVendorPath(),
26-
'DB_NAME' => $facts->getDatabaseName(),
27-
'DB_USERNAME' => $facts->getDatabaseUserName(),
28-
'DB_PASSWORD' => $facts->getDatabasePassword(),
29-
'DB_HOST' => $facts->getDatabaseHost(),
30-
'DB_PORT' => $facts->getDatabasePort(),
31-
'MODULE_DUMP_PATH' => getModuleTestDataDumpFilePath(),
32-
'MYSQL_CONFIG_PATH' => getMysqlConfigPath(),
33-
'PHP_BIN' => $php,
34-
];
35-
36-
function getModuleTestDataDumpFilePath()
37-
{
38-
return Path::join(__DIR__, '..', 'Support', 'Data', 'dump.sql');
39-
}
40-
41-
function getMysqlConfigPath()
42-
{
43-
$facts = new Facts();
44-
$configFile = new ConfigFile($facts->getSourcePath() . '/config.inc.php');
45-
46-
$generator = new DatabaseDefaultsFileGenerator($configFile);
47-
48-
return $generator->generate();
49-
}
12+
return (new CodeceptionParametersProvider())->getParameters();

0 commit comments

Comments
 (0)