Skip to content

Commit 2bff921

Browse files
committed
test(db-command): cover recorded path without loading the drop-in
1 parent 91d7694 commit 2bff921

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

‎features/db-sqlite-path.feature‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,39 @@ Feature: Select the configured SQLite database for file operations
100100
{OTHER_HASH}
101101
"""
102102

103+
@require-sqlite
104+
Scenario: Resolve the recorded secret path without loading the drop-in
105+
Given a WP install
106+
When I run `wp eval 'mkdir( "recorded" ); copy( defined( "DB_PATH" ) ? DB_PATH : FQDB, "recorded/selected.sqlite" ); copy( "recorded/selected.sqlite", ".ht.sqlite" ); file_put_contents( "recorded/db-path.php", "<?php return " . var_export( getcwd() . "/recorded/selected.sqlite", true ) . ";" );'`
107+
And I run `sqlite3 recorded/selected.sqlite "CREATE TABLE path_marker (value TEXT); INSERT INTO path_marker VALUES ('selected');"`
108+
And I run `sqlite3 .ht.sqlite "CREATE TABLE path_marker (value TEXT); INSERT INTO path_marker VALUES ('other');"`
109+
110+
Given a paths.php file:
111+
"""
112+
<?php
113+
define( 'DB_ENGINE', 'sqlite' );
114+
define( 'FQDBDIR', __DIR__ . '/recorded/' );
115+
"""
116+
When I run `wp config set path_constants "require __DIR__ . '/paths.php'" --type=variable --raw`
117+
And I try `wp eval 'echo "ready";'`
118+
Then the return code should be 0
119+
120+
# Remove the drop-in so no DB_PATH or FQDB constant can be defined
121+
# before get_sqlite_db_path() runs. Only the recorded-path branch can
122+
# resolve this database.
123+
When I run `rm wp-content/db.php`
124+
125+
And I try `wp db export selected.sql`
126+
Then the return code should be 0
127+
And the selected.sql file should contain:
128+
"""
129+
INSERT INTO path_marker VALUES('selected');
130+
"""
131+
And the selected.sql file should not contain:
132+
"""
133+
INSERT INTO path_marker VALUES('other');
134+
"""
135+
103136
Scenario Outline: Reject file operations on an in-memory SQLite database
104137
Given a WP install
105138
And an input.sql file:

0 commit comments

Comments
 (0)