Skip to content

Commit 560ed5c

Browse files
authored
Merge pull request #188 from wp-cli/fix/sqlite-custom-wp-content
2 parents b452014 + e6d8b18 commit 560ed5c

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

features/testing.feature

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,14 @@ Feature: Test that WP-CLI loads.
4141
"""
4242
false
4343
"""
44+
45+
@require-sqlite
46+
Scenario: Custom wp-content directory
47+
Given a WP install
48+
And a custom wp-content directory
49+
50+
When I run `wp eval 'echo DB_ENGINE;'`
51+
Then STDOUT should contain:
52+
"""
53+
sqlite
54+
"""

src/Context/GivenStepDefinitions.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,19 @@ public function given_a_custom_wp_directory() {
176176
);
177177

178178
file_put_contents( $wp_config_path, $wp_config_code );
179+
180+
if ( 'sqlite' === self::$db_type ) {
181+
$db_dropin = $this->variables['RUN_DIR'] . '/my-content/db.php';
182+
183+
/* similar to https://github.com/WordPress/sqlite-database-integration/blob/3306576c9b606bc23bbb26c15383fef08e03ab11/activate.php#L95 */
184+
$file_contents = str_replace(
185+
'plugins/',
186+
'../my-plugins/',
187+
file_get_contents( $db_dropin )
188+
);
189+
190+
file_put_contents( $db_dropin, $file_contents );
191+
}
179192
}
180193

181194
/**

0 commit comments

Comments
 (0)