-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathdb-import.feature
More file actions
230 lines (185 loc) · 6.15 KB
/
db-import.feature
File metadata and controls
230 lines (185 loc) · 6.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
Feature: Import a WordPress database
Scenario: Import from database name path by default
Given a WP install
When I run `wp db export wp_cli_test.sql`
Then the wp_cli_test.sql file should exist
When I run `wp db import`
Then STDOUT should be:
"""
Success: Imported from 'wp_cli_test.sql'.
"""
Scenario: Import from database name path by default with mysql defaults
Given a WP install
When I run `wp db export wp_cli_test.sql`
Then the wp_cli_test.sql file should exist
When I run `wp db import --defaults`
Then STDOUT should be:
"""
Success: Imported from 'wp_cli_test.sql'.
"""
Scenario: Import from database name path by default with --no-defaults
Given a WP install
When I run `wp db export wp_cli_test.sql`
Then the wp_cli_test.sql file should exist
When I run `wp db import --no-defaults`
Then STDOUT should be:
"""
Success: Imported from 'wp_cli_test.sql'.
"""
@require-mysql-or-mariadb
Scenario: Import from STDIN
Given a WP install
When I run `wp db import -`
Then STDOUT should be:
"""
Success: Imported from 'STDIN'.
"""
# TODO: Debug the difference here.
@require-sqlite
Scenario: Import from STDIN
Given a WP install
When I run `echo "" | wp db import -`
Then STDOUT should be:
"""
Success: Imported from 'STDIN'.
"""
Scenario: Import from database name path by default and skip speed optimization
Given a WP install
When I run `wp db export wp_cli_test.sql`
Then the wp_cli_test.sql file should exist
When I run `wp db import --skip-optimization`
Then STDOUT should be:
"""
Success: Imported from 'wp_cli_test.sql'.
"""
# SQLite doesn't support the --dbuser flag.
@require-mysql-or-mariadb
Scenario: Import from database name path by default with passed-in dbuser/dbpass
Given a WP install
When I run `wp db export wp_cli_test.sql`
Then the wp_cli_test.sql file should exist
When I run `wp db import --dbuser=wp_cli_test --dbpass=password1`
Then STDOUT should be:
"""
Success: Imported from 'wp_cli_test.sql'.
"""
When I try `wp db import --dbuser=wp_cli_test --dbpass=no_such_pass`
Then the return code should not be 0
And STDERR should contain:
"""
Access denied
"""
And STDOUT should be empty
# SQLite doesn't support the --force flag.
@require-mysql-or-mariadb
Scenario: Import database with passed-in options
Given a WP install
And a debug.sql file:
"""
INSERT INTO `wp_options` (`option_id`, `option_name`, `option_value`, `autoload`) VALUES (999, 'testoption', 'testval', 'yes'),(999, 'testoption', 'testval', 'yes');
"""
When I try `wp db import debug.sql --force`
Then STDOUT should be:
"""
Success: Imported from 'debug.sql'.
"""
# For SQLite this would fail at the `wp db create` step
# because of the missing plugin/drop-in.
@require-mysql-or-mariadb
Scenario: Help runs properly at various points of a functional WP install
Given an empty directory
When I run `wp help db import`
Then STDOUT should contain:
"""
wp db import
"""
When I run `wp core download`
Then STDOUT should not be empty
And the wp-config-sample.php file should exist
When I run `wp help db import`
Then STDOUT should contain:
"""
wp db import
"""
When I run `wp core config {CORE_CONFIG_SETTINGS}`
Then STDOUT should not be empty
And the wp-config.php file should exist
When I run `wp help db import`
Then STDOUT should contain:
"""
wp db import
"""
When I run `wp db create`
Then STDOUT should not be empty
When I run `wp help db import`
Then STDOUT should contain:
"""
wp db import
"""
@require-mysql-or-mariadb
Scenario: MySQL defaults are available as appropriate with --defaults flag
Given a WP install
When I run `wp db export wp_cli_test.sql`
Then the wp_cli_test.sql file should exist
When I try `wp db import --defaults --debug`
Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysql|mariadb) --no-auto-rehash#
When I try `wp db import --debug`
Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysql|mariadb) --no-defaults --no-auto-rehash#
When I try `wp db import --no-defaults --debug`
Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysql|mariadb) --no-defaults --no-auto-rehash#
@require-mysql-or-mariadb
Scenario: Import db that has emoji in post
Given a WP install
When I run `wp post create --post_title="🍣"`
And I run `wp post list`
Then the return code should be 0
And STDOUT should contain:
"""
🍣
"""
When I try `wp db export wp_cli_test.sql --debug`
Then the return code should be 0
And the wp_cli_test.sql file should exist
And STDERR should contain:
"""
Detected character set of the posts table: utf8mb4
"""
And STDERR should contain:
"""
Setting missing default character set to utf8mb4
"""
When I run `wp db import --dbuser=wp_cli_test --dbpass=password1`
Then STDOUT should be:
"""
Success: Imported from 'wp_cli_test.sql'.
"""
When I run `wp post list`
Then the return code should be 0
And STDOUT should contain:
"""
🍣
"""
@require-sqlite
Scenario: Import db that has emoji in post
Given a WP install
When I run `wp post create --post_title="🍣"`
And I run `wp post list`
Then the return code should be 0
And STDOUT should contain:
"""
🍣
"""
When I try `wp db export wp_cli_test.sql --debug`
Then the return code should be 0
And the wp_cli_test.sql file should exist
When I run `wp db import --dbuser=wp_cli_test --dbpass=password1`
Then STDOUT should be:
"""
Success: Imported from 'wp_cli_test.sql'.
"""
When I run `wp post list`
Then the return code should be 0
And STDOUT should contain:
"""
🍣
"""