Skip to content

Commit

Permalink
Merge pull request #188 from wp-cli/fix/sqlite-custom-wp-content
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera authored Oct 24, 2023
2 parents b452014 + e6d8b18 commit 560ed5c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions features/testing.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,14 @@ Feature: Test that WP-CLI loads.
"""
false
"""

@require-sqlite
Scenario: Custom wp-content directory
Given a WP install
And a custom wp-content directory

When I run `wp eval 'echo DB_ENGINE;'`
Then STDOUT should contain:
"""
sqlite
"""
13 changes: 13 additions & 0 deletions src/Context/GivenStepDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,19 @@ public function given_a_custom_wp_directory() {
);

file_put_contents( $wp_config_path, $wp_config_code );

if ( 'sqlite' === self::$db_type ) {
$db_dropin = $this->variables['RUN_DIR'] . '/my-content/db.php';

/* similar to https://github.com/WordPress/sqlite-database-integration/blob/3306576c9b606bc23bbb26c15383fef08e03ab11/activate.php#L95 */
$file_contents = str_replace(
'plugins/',
'../my-plugins/',
file_get_contents( $db_dropin )
);

file_put_contents( $db_dropin, $file_contents );
}
}

/**
Expand Down

0 comments on commit 560ed5c

Please sign in to comment.