Skip to content

Commit 6204e92

Browse files
committed
Fix env files for the codeception tests
1 parent 5c2785a commit 6204e92

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

.codeception.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extensions:
1010
- Codeception\Extension\RunFailed
1111
params:
1212
- env
13-
- .env.development
13+
- .codeception/_config/params.php
1414
settings:
1515
backup_globals: false
1616
colors: true

.codeception/_config/params.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Loads configuration parameters.
4+
*
5+
* Don't modify this file directly.
6+
* Create and use 'params.local.php' instead.
7+
*
8+
* @since {VERSION}
9+
* @link {URL}
10+
* @license GPLv2 or later
11+
* @package PluginName
12+
* @author {AUTHOR}
13+
*/
14+
15+
use Codeception\Exception\ConfigurationException;
16+
use Codeception\Lib\ParamsLoader;
17+
18+
global $argv;
19+
20+
if ( ! in_array( 'acceptance', $argv, true ) ) {
21+
return [];
22+
}
23+
24+
if ( ! in_array( 'github-actions', $argv, true ) ) {
25+
try {
26+
( new ParamsLoader() )->load( '.env.development' );
27+
} catch ( ConfigurationException $e ) {
28+
throw new Exception( 'If you wan\'t to run your tests locally, then create the `.env.development` configuration file.' );
29+
}
30+
}
31+
32+
return [
33+
'WP_URL' => getenv( 'WP_URL' ),
34+
'WP_ADMIN_USERNAME' => getenv( 'WP_ADMIN_USERNAME' ),
35+
'WP_ADMIN_PASSWORD' => getenv( 'WP_ADMIN_PASSWORD' ),
36+
'WP_ADMIN_PATH' => getenv( 'WP_ADMIN_PATH' ),
37+
'DB_HOST' => getenv( 'DB_HOST' ),
38+
'DB_NAME' => getenv( 'DB_NAME' ),
39+
'DB_USER' => getenv( 'DB_USER' ),
40+
'DB_PASSWORD' => getenv( 'DB_PASSWORD' ),
41+
'DB_TABLE_PREFIX' => getenv( 'DB_TABLE_PREFIX' ),
42+
];
43+

0 commit comments

Comments
 (0)