Skip to content

Commit

Permalink
テスト用configファイルがある時は切り替える #1013
Browse files Browse the repository at this point in the history
  • Loading branch information
clicktx committed Sep 29, 2024
1 parent 74eaa0a commit b95b601
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
9 changes: 8 additions & 1 deletion data/class/SC_Initial.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ public function init()
*/
public function requireInitialConfig()
{
define('CONFIG_REALFILE', realpath(dirname(__FILE__)) . '/../config/config.php');
$testConfig = realpath(dirname(__FILE__)) . '/../config/config4test.php';
$configPath = realpath(dirname(__FILE__)) . '/../config/config.php';

Check warning on line 72 in data/class/SC_Initial.php

View check run for this annotation

Codecov / codecov/patch

data/class/SC_Initial.php#L71-L72

Added lines #L71 - L72 were not covered by tests
// テスト実行にはテスト用configファイルに
if (defined('TEST_FUNCTION') && TEST_FUNCTION && file_exists($testConfig)) {
$configPath = $testConfig;

Check warning on line 75 in data/class/SC_Initial.php

View check run for this annotation

Codecov / codecov/patch

data/class/SC_Initial.php#L74-L75

Added lines #L74 - L75 were not covered by tests
}
define('CONFIG_REALFILE', $configPath);

Check warning on line 77 in data/class/SC_Initial.php

View check run for this annotation

Codecov / codecov/patch

data/class/SC_Initial.php#L77

Added line #L77 was not covered by tests

if (file_exists(CONFIG_REALFILE)) {
require_once CONFIG_REALFILE;

Expand Down
27 changes: 27 additions & 0 deletions data/config/config4test.php.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

// テスト実行時に使用する設定ファイル
// config4test.phpにリネームして配置するとテスト実行時に使用されます。
define('ECCUBE_INSTALL', 'ON');
define('HTTP_URL', 'http://example.com/eccube/html/');
define('HTTPS_URL', 'https://example.com/eccube/html/');
define('ROOT_URLPATH', '/eccube/html/path/');
define('DOMAIN_NAME', '');
define('DB_TYPE', 'pgsql_or_mysql');
define('DB_USER', 'your_db_user');
define('DB_PASSWORD', 'your_password');
define('DB_SERVER', 'db_server');
define('DB_NAME', 'eccube_db_name');
define('DB_PORT', '');
define('ADMIN_DIR', 'admin/');
define('ADMIN_FORCE_SSL', TRUE);
define('ADMIN_ALLOW_HOSTS', 'a:0:{}');
define('AUTH_MAGIC', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
define('PASSWORD_HASH_ALGOS', 'sha256');
define('MAIL_BACKEND', 'smtp');
define('SMTP_HOST', 'mailcatcher');
define('SMTP_PORT', '25');
define('SMTP_USER', '');
define('SMTP_PASSWORD', '');

define('TEST_MAILCATCHER_URL', 'http://127.0.0.1:1080');

0 comments on commit b95b601

Please sign in to comment.