Skip to content

Commit 70cea78

Browse files
author
Chris Wiegman
committed
Update behat tests per feedback
1 parent d399adf commit 70cea78

File tree

4 files changed

+62
-11
lines changed

4 files changed

+62
-11
lines changed

features/db-check.feature

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ Feature: Check the database
1313
Success: Database checked.
1414
"""
1515

16+
Scenario: Run db check with MySQL defaults to check the database
17+
Given a WP install
18+
19+
When I run `wp db check --defaults`
20+
Then STDOUT should contain:
21+
"""
22+
wp_cli_test.wp_users
23+
"""
24+
And STDOUT should contain:
25+
"""
26+
Success: Database checked.
27+
"""
28+
1629
Scenario: Run db check with passed-in options
1730
Given a WP install
1831

@@ -104,11 +117,11 @@ Feature: Check the database
104117
When I try `wp db check --defaults --debug`
105118
Then STDERR should contain:
106119
"""
107-
Debug (db): /usr/bin/env mysqlcheck %s
120+
Debug (db): Running shell command: /usr/bin/env mysqlcheck %s
108121
"""
109122

110123
When I try `wp db check --debug`
111124
Then STDERR should contain:
112125
"""
113-
Debug (db): /usr/bin/env mysqlcheck --no-defaults %s
126+
Debug (db): Running shell command: /usr/bin/env mysqlcheck --no-defaults %s
114127
"""

features/db-export.feature

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ Feature: Export a WordPress database
4343
-- MySQL dump
4444
"""
4545

46+
Scenario: Export database with mysql defaults to STDOUT
47+
Given a WP install
48+
49+
When I run `wp db export --defaults -`
50+
Then STDOUT should contain:
51+
"""
52+
-- MySQL dump
53+
"""
54+
4655
Scenario: Export database with passed-in options
4756
Given a WP install
4857

@@ -60,17 +69,17 @@ Feature: Export a WordPress database
6069
"""
6170
And STDOUT should be empty
6271

63-
Scenario: Ensure MySQL defaults are available when as appropriate with --defaults flag
72+
Scenario: MySQL defaults are available as appropriate with --defaults flag
6473
Given a WP install
6574

6675
When I try `wp db export --defaults --debug`
6776
Then STDERR should contain:
6877
"""
69-
Debug (db): /usr/bin/env mysqldump
78+
Debug (db): Running initial shell command: /usr/bin/env mysqldump
7079
"""
7180

7281
When I try `wp db export --debug`
7382
Then STDERR should contain:
7483
"""
75-
Debug (db): /usr/bin/env mysqldump --no-defaults
84+
Debug (db): Running initial shell command: /usr/bin/env mysqldump --no-defaults
7685
"""

features/db-import.feature

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ Feature: Import a WordPress database
1212
Success: Imported from 'wp_cli_test.sql'.
1313
"""
1414

15+
Scenario: Import from database name path by default with mysql defaults
16+
Given a WP install
17+
18+
When I run `wp db export wp_cli_test.sql`
19+
Then the wp_cli_test.sql file should exist
20+
21+
When I run `wp db import --defaults`
22+
Then STDOUT should be:
23+
"""
24+
Success: Imported from 'wp_cli_test.sql'.
25+
"""
26+
1527
Scenario: Import from STDIN
1628
Given a WP install
1729

@@ -104,7 +116,7 @@ Feature: Import a WordPress database
104116
"""
105117
wp db import
106118
"""
107-
Scenario: Ensure MySQL defaults are available when as appropriate with --defaults flag
119+
Scenario: MySQL defaults are available as appropriate with --defaults flag
108120
Given a WP install
109121

110122
When I run `wp db export wp_cli_test.sql`
@@ -113,11 +125,11 @@ Feature: Import a WordPress database
113125
When I try `wp db import --defaults --debug`
114126
Then STDERR should contain:
115127
"""
116-
Debug (db): /usr/bin/env mysql --no-auto-rehash
128+
Debug (db): Running shell command: /usr/bin/env mysql --no-auto-rehash
117129
"""
118130

119131
When I try `wp db import --debug`
120132
Then STDERR should contain:
121133
"""
122-
Debug (db): /usr/bin/env mysql --no-defaults --no-auto-rehash
134+
Debug (db): Running shell command: /usr/bin/env mysql --no-defaults --no-auto-rehash
123135
"""

features/db-query.feature

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,34 @@ Feature: Query the database with WordPress' MySQL config
3838
"""
3939
And STDOUT should be empty
4040

41-
Scenario: Ensure MySQL defaults are available when as appropriate with --defaults flag
41+
Scenario: Database querying with MySQL defaults and passed-in options
42+
Given a WP install
43+
44+
When I run `wp db query --defaults "SELECT COUNT(ID) FROM wp_posts;" --dbuser=wp_cli_test --html`
45+
Then STDOUT should contain:
46+
"""
47+
<TABLE
48+
"""
49+
50+
When I try `wp db query --defaults "SELECT COUNT(ID) FROM wp_posts;" --dbuser=no_such_user`
51+
Then the return code should not be 0
52+
And STDERR should contain:
53+
"""
54+
Access denied
55+
"""
56+
And STDOUT should be empty
57+
58+
Scenario: MySQL defaults are available as appropriate with --defaults flag
4259
Given a WP install
4360

4461
When I try `wp db query --defaults --debug`
4562
Then STDERR should contain:
4663
"""
47-
Debug (db): /usr/bin/env mysql --no-auto-rehash
64+
Debug (db): Running shell command: /usr/bin/env mysql --no-auto-rehash
4865
"""
4966

5067
When I try `wp db query --debug`
5168
Then STDERR should contain:
5269
"""
53-
Debug (db): /usr/bin/env mysql --no-defaults --no-auto-rehash
70+
Debug (db): Running shell command: /usr/bin/env mysql --no-defaults --no-auto-rehash
5471
"""

0 commit comments

Comments
 (0)