@@ -61,6 +61,87 @@ Feature: Select the configured SQLite database for file operations
6161 | | selected .sqlite | | | |
6262 | | | | selected .sqlite | / |
6363
64+ Scenario : Resolve an explicit DB_PATH located outside the web root
65+ Given a WP install
66+ When I run `wp eval '$outside = dirname( getcwd() ) . "/db-outside.sqlite"; copy( defined( "DB_PATH" ) ? DB_PATH : FQDB, $outside ); copy( $outside, getcwd() . "/other.sqlite" );' `
67+ And I run `sqlite3 ../db-outside.sqlite "CREATE TABLE path_marker (value TEXT); INSERT INTO path_marker VALUES ('selected');" `
68+ And I run `sqlite3 other.sqlite "CREATE TABLE path_marker (value TEXT); INSERT INTO path_marker VALUES ('other');" `
69+
70+ Given a paths.php file:
71+ """
72+ <?php
73+ define( 'DB_PATH', dirname( __DIR__ ) . '/db-outside.sqlite' );
74+ define( 'FQDB', __DIR__ . '/other.sqlite' );
75+ define( 'FQDBDIR', __DIR__ . '/other/' );
76+ define( 'DB_FILE', 'other.sqlite' );
77+ """
78+ When I run `wp config set path_constants "require __DIR__ . '/paths.php'" --type=variable --raw`
79+ And I try `wp eval 'echo "ready";' `
80+ Then the return code should be 0
81+
82+ When I run `wp eval 'echo md5_file( "other.sqlite" );' --skip-wordpress`
83+ Then save STDOUT as {OTHER_HASH}
84+
85+ When I try `wp db export selected.sql`
86+ Then the return code should be 0
87+ And the selected.sql file should contain:
88+ """
89+ INSERT INTO path_marker VALUES('selected');
90+ """
91+ And the selected.sql file should not contain:
92+ """
93+ INSERT INTO path_marker VALUES('other');
94+ """
95+
96+ When I try `wp db drop --yes`
97+ Then the return code should be 0
98+ And the ../db-outside.sqlite file should not exist
99+
100+ When I run `wp eval 'echo md5_file( "other.sqlite" );' --skip-wordpress`
101+ Then STDOUT should be:
102+ """
103+ {OTHER_HASH}
104+ """
105+
106+ Scenario : Resolve the recorded secret path from db-path.php
107+ Given a WP install
108+ 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 ) . ";" );' `
109+ And I run `sqlite3 recorded/selected.sqlite "CREATE TABLE path_marker (value TEXT); INSERT INTO path_marker VALUES ('selected');" `
110+ And I run `sqlite3 .ht.sqlite "CREATE TABLE path_marker (value TEXT); INSERT INTO path_marker VALUES ('other');" `
111+
112+ Given a paths.php file:
113+ """
114+ <?php
115+ define( 'FQDBDIR', __DIR__ . '/recorded/' );
116+ """
117+ When I run `wp config set path_constants "require __DIR__ . '/paths.php'" --type=variable --raw`
118+ And I try `wp eval 'echo "ready";' `
119+ Then the return code should be 0
120+
121+ When I run `wp eval 'echo md5_file( ".ht.sqlite" );' --skip-wordpress`
122+ Then save STDOUT as {OTHER_HASH}
123+
124+ When I try `wp db export selected.sql`
125+ Then the return code should be 0
126+ And the selected.sql file should contain:
127+ """
128+ INSERT INTO path_marker VALUES('selected');
129+ """
130+ And the selected.sql file should not contain:
131+ """
132+ INSERT INTO path_marker VALUES('other');
133+ """
134+
135+ When I try `wp db drop --yes`
136+ Then the return code should be 0
137+ And the recorded/selected.sqlite file should not exist
138+
139+ When I run `wp eval 'echo md5_file( ".ht.sqlite" );' --skip-wordpress`
140+ Then STDOUT should be:
141+ """
142+ {OTHER_HASH}
143+ """
144+
64145 Scenario Outline : Reject file operations on an in-memory SQLite database
65146 Given a WP install
66147 And an input.sql file:
0 commit comments