Skip to content

Commit 322c711

Browse files
authored
Merge pull request #357 from wp-cli/fix/test-db-name
Expect the configured test database name and user
2 parents 685e740 + ba425d9 commit 322c711

6 files changed

Lines changed: 87 additions & 87 deletions

File tree

‎features/db-check.feature‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Feature: Check the database
77
When I run `wp db check`
88
Then STDOUT should contain:
99
"""
10-
wp_cli_test.wp_users
10+
{DB_NAME}.wp_users
1111
"""
1212
And STDOUT should contain:
1313
"""
@@ -28,7 +28,7 @@ Feature: Check the database
2828
When I run `wp db check --silent`
2929
Then STDOUT should not contain:
3030
"""
31-
wp_cli_test.wp_users
31+
{DB_NAME}.wp_users
3232
"""
3333
And STDOUT should contain:
3434
"""
@@ -42,7 +42,7 @@ Feature: Check the database
4242
When I run `wp db check --defaults`
4343
Then STDOUT should contain:
4444
"""
45-
wp_cli_test.wp_users
45+
{DB_NAME}.wp_users
4646
"""
4747
And STDOUT should contain:
4848
"""
@@ -56,7 +56,7 @@ Feature: Check the database
5656
When I run `wp db check --no-defaults`
5757
Then STDOUT should contain:
5858
"""
59-
wp_cli_test.wp_users
59+
{DB_NAME}.wp_users
6060
"""
6161
And STDOUT should contain:
6262
"""
@@ -67,7 +67,7 @@ Feature: Check the database
6767
Scenario: Run db check with passed-in options
6868
Given a WP install
6969

70-
When I run `wp db check --dbuser=wp_cli_test`
70+
When I run `wp db check --dbuser={DB_USER}`
7171
Then STDOUT should contain:
7272
"""
7373
Success: Database checked.
@@ -79,7 +79,7 @@ Feature: Check the database
7979
Success: Database checked.
8080
"""
8181

82-
When I run `wp db check --dbuser=wp_cli_test --dbpass=password1`
82+
When I run `wp db check --dbuser={DB_USER} --dbpass=password1`
8383
Then STDOUT should contain:
8484
"""
8585
Success: Database checked.
@@ -101,7 +101,7 @@ Feature: Check the database
101101
"""
102102
And STDOUT should be empty
103103

104-
When I try `wp db check --dbuser=wp_cli_test --verbose`
104+
When I try `wp db check --dbuser={DB_USER} --verbose`
105105
Then the return code should be 0
106106
And STDOUT should contain:
107107
"""

‎features/db-export.feature‎

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,59 @@ Feature: Export a WordPress database
66
When I run `wp db export --porcelain`
77
Then STDOUT should contain:
88
"""
9-
wp_cli_test-
9+
{DB_NAME}-
1010
"""
11-
And the wp_cli_test.sql file should not exist
11+
And the {DB_NAME}.sql file should not exist
1212

1313
Scenario: Database export to a specified file path
1414
Given a WP install
1515

16-
When I run `wp db export wp_cli_test.sql --porcelain`
16+
When I run `wp db export {DB_NAME}.sql --porcelain`
1717
Then STDOUT should contain:
1818
"""
19-
wp_cli_test.sql
19+
{DB_NAME}.sql
2020
"""
21-
And the wp_cli_test.sql file should exist
21+
And the {DB_NAME}.sql file should exist
2222

2323
@skip-sqlite
2424
Scenario: Exclude tables when exporting the database
2525
Given a WP install
2626

27-
When I try `wp db export wp_cli_test.sql --exclude_tables=wp_users --porcelain`
28-
Then the wp_cli_test.sql file should exist
29-
And the contents of the wp_cli_test.sql file should not match /CREATE TABLE ["`]?wp_users["`]?/
30-
And the contents of the wp_cli_test.sql file should match /CREATE TABLE ["`]?wp_options["`]?/
27+
When I try `wp db export {DB_NAME}.sql --exclude_tables=wp_users --porcelain`
28+
Then the {DB_NAME}.sql file should exist
29+
And the contents of the {DB_NAME}.sql file should not match /CREATE TABLE ["`]?wp_users["`]?/
30+
And the contents of the {DB_NAME}.sql file should match /CREATE TABLE ["`]?wp_options["`]?/
3131

3232
@skip-sqlite
3333
Scenario: Include only specific tables when exporting the database
3434
Given a WP install
3535

36-
When I try `wp db export wp_cli_test.sql --tables=wp_users --porcelain`
37-
Then the wp_cli_test.sql file should exist
38-
And the contents of the wp_cli_test.sql file should match /CREATE TABLE ["`]?wp_users["`]?/
39-
And the contents of the wp_cli_test.sql file should not match /CREATE TABLE ["`]?wp_posts["`]?/
40-
And the contents of the wp_cli_test.sql file should not match /CREATE TABLE ["`]?wp_options["`]?/
36+
When I try `wp db export {DB_NAME}.sql --tables=wp_users --porcelain`
37+
Then the {DB_NAME}.sql file should exist
38+
And the contents of the {DB_NAME}.sql file should match /CREATE TABLE ["`]?wp_users["`]?/
39+
And the contents of the {DB_NAME}.sql file should not match /CREATE TABLE ["`]?wp_posts["`]?/
40+
And the contents of the {DB_NAME}.sql file should not match /CREATE TABLE ["`]?wp_options["`]?/
4141

4242
@require-sqlite
4343
Scenario: Exclude tables when exporting the database
4444
Given a WP install
4545

46-
When I try `wp db export wp_cli_test.sql --exclude_tables=wp_users --porcelain`
47-
Then the wp_cli_test.sql file should exist
48-
And the contents of the wp_cli_test.sql file should not match /_mysql_data_types_cache/
49-
And the contents of the wp_cli_test.sql file should not match /CREATE TABLE ["`]?wp_users["`]?/
50-
And the contents of the wp_cli_test.sql file should match /CREATE TABLE ["`]?wp_options["`]?/
46+
When I try `wp db export {DB_NAME}.sql --exclude_tables=wp_users --porcelain`
47+
Then the {DB_NAME}.sql file should exist
48+
And the contents of the {DB_NAME}.sql file should not match /_mysql_data_types_cache/
49+
And the contents of the {DB_NAME}.sql file should not match /CREATE TABLE ["`]?wp_users["`]?/
50+
And the contents of the {DB_NAME}.sql file should match /CREATE TABLE ["`]?wp_options["`]?/
5151

5252
@require-sqlite
5353
Scenario: Include only specific tables when exporting the database
5454
Given a WP install
5555

56-
When I try `wp db export wp_cli_test.sql --tables=wp_users --porcelain`
57-
Then the wp_cli_test.sql file should exist
58-
And the contents of the wp_cli_test.sql file should not match /_mysql_data_types_cache/
59-
And the contents of the wp_cli_test.sql file should match /CREATE TABLE ["`]?wp_users["`]?/
60-
And the contents of the wp_cli_test.sql file should not match /CREATE TABLE ["`]?wp_posts["`]?/
61-
And the contents of the wp_cli_test.sql file should not match /CREATE TABLE ["`]?wp_options["`]?/
56+
When I try `wp db export {DB_NAME}.sql --tables=wp_users --porcelain`
57+
Then the {DB_NAME}.sql file should exist
58+
And the contents of the {DB_NAME}.sql file should not match /_mysql_data_types_cache/
59+
And the contents of the {DB_NAME}.sql file should match /CREATE TABLE ["`]?wp_users["`]?/
60+
And the contents of the {DB_NAME}.sql file should not match /CREATE TABLE ["`]?wp_posts["`]?/
61+
And the contents of the {DB_NAME}.sql file should not match /CREATE TABLE ["`]?wp_options["`]?/
6262

6363
@require-sqlite
6464
Scenario: Export database to STDOUT
@@ -153,10 +153,10 @@ Feature: Export a WordPress database
153153
Scenario: Export database when PHP exec() is disabled
154154
Given a WP install
155155

156-
When I try `{INVOKE_WP_CLI_WITH_PHP_ARGS--ddisable_functions=exec} db export wp_cli_test.sql --porcelain`
156+
When I try `{INVOKE_WP_CLI_WITH_PHP_ARGS--ddisable_functions=exec} db export {DB_NAME}.sql --porcelain`
157157
Then the return code should be 0
158158
And STDOUT should contain:
159159
"""
160-
wp_cli_test.sql
160+
{DB_NAME}.sql
161161
"""
162-
And the wp_cli_test.sql file should exist
162+
And the {DB_NAME}.sql file should exist

‎features/db-import.feature‎

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,37 @@ Feature: Import a WordPress database
33
Scenario: Import from database name path by default
44
Given a WP install
55

6-
When I run `wp db export wp_cli_test.sql`
7-
Then the wp_cli_test.sql file should exist
6+
When I run `wp db export {DB_NAME}.sql`
7+
Then the {DB_NAME}.sql file should exist
88

99
When I run `wp db import`
1010
Then STDOUT should be:
1111
"""
12-
Success: Imported from 'wp_cli_test.sql'.
12+
Success: Imported from '{DB_NAME}.sql'.
1313
"""
1414

1515
Scenario: Import from database name path by default with mysql defaults
1616
Given a WP install
1717

18-
When I run `wp db export wp_cli_test.sql`
19-
Then the wp_cli_test.sql file should exist
18+
When I run `wp db export {DB_NAME}.sql`
19+
Then the {DB_NAME}.sql file should exist
2020

2121
When I run `wp db import --defaults`
2222
Then STDOUT should be:
2323
"""
24-
Success: Imported from 'wp_cli_test.sql'.
24+
Success: Imported from '{DB_NAME}.sql'.
2525
"""
2626

2727
Scenario: Import from database name path by default with --no-defaults
2828
Given a WP install
2929

30-
When I run `wp db export wp_cli_test.sql`
31-
Then the wp_cli_test.sql file should exist
30+
When I run `wp db export {DB_NAME}.sql`
31+
Then the {DB_NAME}.sql file should exist
3232

3333
When I run `wp db import --no-defaults`
3434
Then STDOUT should be:
3535
"""
36-
Success: Imported from 'wp_cli_test.sql'.
36+
Success: Imported from '{DB_NAME}.sql'.
3737
"""
3838

3939
@require-mysql-or-mariadb
@@ -60,30 +60,30 @@ Feature: Import a WordPress database
6060
Scenario: Import from database name path by default and skip speed optimization
6161
Given a WP install
6262

63-
When I run `wp db export wp_cli_test.sql`
64-
Then the wp_cli_test.sql file should exist
63+
When I run `wp db export {DB_NAME}.sql`
64+
Then the {DB_NAME}.sql file should exist
6565

6666
When I run `wp db import --skip-optimization`
6767
Then STDOUT should be:
6868
"""
69-
Success: Imported from 'wp_cli_test.sql'.
69+
Success: Imported from '{DB_NAME}.sql'.
7070
"""
7171

7272
# SQLite doesn't support the --dbuser flag.
7373
@require-mysql-or-mariadb
7474
Scenario: Import from database name path by default with passed-in dbuser/dbpass
7575
Given a WP install
7676

77-
When I run `wp db export wp_cli_test.sql`
78-
Then the wp_cli_test.sql file should exist
77+
When I run `wp db export {DB_NAME}.sql`
78+
Then the {DB_NAME}.sql file should exist
7979

80-
When I run `wp db import --dbuser=wp_cli_test --dbpass=password1`
80+
When I run `wp db import --dbuser={DB_USER} --dbpass=password1`
8181
Then STDOUT should be:
8282
"""
83-
Success: Imported from 'wp_cli_test.sql'.
83+
Success: Imported from '{DB_NAME}.sql'.
8484
"""
8585

86-
When I try `wp db import --dbuser=wp_cli_test --dbpass=no_such_pass`
86+
When I try `wp db import --dbuser={DB_USER} --dbpass=no_such_pass`
8787
Then the return code should not be 0
8888
And STDERR should contain:
8989
"""
@@ -116,10 +116,10 @@ Feature: Import a WordPress database
116116
Scenario: Import forwards the --ssl flag to the MySQL client
117117
Given a WP install
118118

119-
When I run `wp db export wp_cli_test.sql`
120-
Then the wp_cli_test.sql file should exist
119+
When I run `wp db export {DB_NAME}.sql`
120+
Then the {DB_NAME}.sql file should exist
121121

122-
When I try `wp db import wp_cli_test.sql --ssl --debug`
122+
When I try `wp db import {DB_NAME}.sql --ssl --debug`
123123
Then STDERR should contain:
124124
"""
125125
--ssl
@@ -170,8 +170,8 @@ Feature: Import a WordPress database
170170
Scenario: MySQL defaults are available as appropriate with --defaults flag
171171
Given a WP install
172172

173-
When I run `wp db export wp_cli_test.sql`
174-
Then the wp_cli_test.sql file should exist
173+
When I run `wp db export {DB_NAME}.sql`
174+
Then the {DB_NAME}.sql file should exist
175175

176176
When I try `wp db import --defaults --debug`
177177
Then STDERR should match #Debug \(db\): Running shell command: /([^/]+/)+(mysql|mariadb) --no-auto-rehash#
@@ -194,9 +194,9 @@ Feature: Import a WordPress database
194194
🍣
195195
"""
196196

197-
When I try `wp db export wp_cli_test.sql --debug`
197+
When I try `wp db export {DB_NAME}.sql --debug`
198198
Then the return code should be 0
199-
And the wp_cli_test.sql file should exist
199+
And the {DB_NAME}.sql file should exist
200200
And STDERR should contain:
201201
"""
202202
Detected character set of the posts table: utf8mb4
@@ -206,10 +206,10 @@ Feature: Import a WordPress database
206206
Setting missing default character set to utf8mb4
207207
"""
208208

209-
When I run `wp db import --dbuser=wp_cli_test --dbpass=password1`
209+
When I run `wp db import --dbuser={DB_USER} --dbpass=password1`
210210
Then STDOUT should be:
211211
"""
212-
Success: Imported from 'wp_cli_test.sql'.
212+
Success: Imported from '{DB_NAME}.sql'.
213213
"""
214214

215215
When I run `wp post list`
@@ -231,14 +231,14 @@ Feature: Import a WordPress database
231231
🍣
232232
"""
233233

234-
When I try `wp db export wp_cli_test.sql --debug`
234+
When I try `wp db export {DB_NAME}.sql --debug`
235235
Then the return code should be 0
236-
And the wp_cli_test.sql file should exist
236+
And the {DB_NAME}.sql file should exist
237237

238-
When I run `wp db import --dbuser=wp_cli_test --dbpass=password1`
238+
When I run `wp db import --dbuser={DB_USER} --dbpass=password1`
239239
Then STDOUT should be:
240240
"""
241-
Success: Imported from 'wp_cli_test.sql'.
241+
Success: Imported from '{DB_NAME}.sql'.
242242
"""
243243

244244
When I run `wp post list`
@@ -316,14 +316,14 @@ Feature: Import a WordPress database
316316
Scenario: `wp db import` adapts the SQL mode via --init-command by default
317317
Given a WP install
318318

319-
When I run `wp db export wp_cli_test.sql`
320-
Then the wp_cli_test.sql file should exist
319+
When I run `wp db export {DB_NAME}.sql`
320+
Then the {DB_NAME}.sql file should exist
321321

322322
# The WordPress-compatibility mode adaptation runs on the same import
323323
# connection via --init-command, so it is visible in the debug output and no
324324
# separate mode probe runs (which is what used to break with custom connection
325325
# options).
326-
When I try `wp db import wp_cli_test.sql --debug`
326+
When I try `wp db import {DB_NAME}.sql --debug`
327327
Then the return code should be 0
328328
And STDERR should contain:
329329
"""
@@ -338,10 +338,10 @@ Feature: Import a WordPress database
338338
Scenario: `wp db import --skip-sql-mode-compat` imports under the server's own SQL modes
339339
Given a WP install
340340

341-
When I run `wp db export wp_cli_test.sql`
342-
Then the wp_cli_test.sql file should exist
341+
When I run `wp db export {DB_NAME}.sql`
342+
Then the {DB_NAME}.sql file should exist
343343

344-
When I try `wp db import wp_cli_test.sql --skip-sql-mode-compat --debug`
344+
When I try `wp db import {DB_NAME}.sql --skip-sql-mode-compat --debug`
345345
Then the return code should be 0
346346
And STDERR should not contain:
347347
"""

‎features/db-query.feature‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Feature: Query the database with WordPress' MySQL config
2626
Scenario: Database querying with passed-in options
2727
Given a WP install
2828

29-
When I run `wp db query "SELECT COUNT(ID) FROM wp_posts;" --dbuser=wp_cli_test --html`
29+
When I run `wp db query "SELECT COUNT(ID) FROM wp_posts;" --dbuser={DB_USER} --html`
3030
Then STDOUT should contain:
3131
"""
3232
<TABLE
@@ -45,7 +45,7 @@ Feature: Query the database with WordPress' MySQL config
4545
Scenario: Database querying with MySQL defaults and passed-in options
4646
Given a WP install
4747

48-
When I run `wp db query --defaults "SELECT COUNT(ID) FROM wp_posts;" --dbuser=wp_cli_test --html`
48+
When I run `wp db query --defaults "SELECT COUNT(ID) FROM wp_posts;" --dbuser={DB_USER} --html`
4949
Then STDOUT should contain:
5050
"""
5151
<TABLE
@@ -64,7 +64,7 @@ Feature: Query the database with WordPress' MySQL config
6464
Scenario: Database querying with --nodefaults and passed-in options
6565
Given a WP install
6666

67-
When I run `wp db query --no-defaults "SELECT COUNT(ID) FROM wp_posts;" --dbuser=wp_cli_test --html`
67+
When I run `wp db query --no-defaults "SELECT COUNT(ID) FROM wp_posts;" --dbuser={DB_USER} --html`
6868
Then STDOUT should contain:
6969
"""
7070
<TABLE

0 commit comments

Comments
 (0)