-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathcore-update-db.feature
More file actions
207 lines (186 loc) · 6.86 KB
/
core-update-db.feature
File metadata and controls
207 lines (186 loc) · 6.86 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
Feature: Update core's database
# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.0+
@require-mysql
Scenario: Update db on a single site
Given a WP install
And a disable_sidebar_check.php file:
"""
<?php
WP_CLI::add_wp_hook( 'init', static function () {
remove_action( 'after_switch_theme', '_wp_sidebars_changed' );
} );
"""
And I try `wp theme install twentytwenty --activate`
And I run `wp core download --version=5.4 --force`
And I run `wp option update db_version 45805 --require=disable_sidebar_check.php`
When I run `wp core update-db`
Then STDOUT should contain:
"""
Success: WordPress database upgraded successfully from db version 45805 to 47018.
"""
When I run `wp core update-db`
Then STDOUT should contain:
"""
Success: WordPress database already at latest db version 47018.
"""
# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.0+
@require-mysql
Scenario: Dry run update db on a single site
Given a WP install
And a disable_sidebar_check.php file:
"""
<?php
WP_CLI::add_wp_hook( 'init', static function () {
remove_action( 'after_switch_theme', '_wp_sidebars_changed' );
} );
"""
And I try `wp theme install twentytwenty --activate`
And I run `wp core download --version=5.4 --force`
And I run `wp option update db_version 45805 --require=disable_sidebar_check.php`
When I run `wp core update-db --dry-run`
Then STDOUT should be:
"""
Performing a dry run, with no database modification.
Success: WordPress database will be upgraded from db version 45805 to 47018.
"""
When I run `wp option get db_version`
Then STDOUT should be:
"""
45805
"""
# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.0+
@require-mysql
Scenario: Update db across network
Given a WP multisite install
And a disable_sidebar_check.php file:
"""
<?php
WP_CLI::add_wp_hook( 'init', static function () {
remove_action( 'after_switch_theme', '_wp_sidebars_changed' );
} );
"""
And I try `wp theme install twentytwenty --activate`
And I run `wp core download --version=5.4 --force`
And I run `wp option update db_version 45805 --require=disable_sidebar_check.php`
And I run `wp site option update wpmu_upgrade_site 45805`
And I run `wp site create --slug=foo`
And I run `wp site create --slug=bar`
And I run `wp site create --slug=burrito --porcelain`
And save STDOUT as {BURRITO_ID}
And I run `wp site create --slug=taco --porcelain`
And save STDOUT as {TACO_ID}
And I run `wp site create --slug=pizza --porcelain`
And save STDOUT as {PIZZA_ID}
And I run `wp site archive {BURRITO_ID}`
And I run `wp site spam {TACO_ID}`
And I run `wp site delete {PIZZA_ID} --yes`
When I run `wp site option get wpmu_upgrade_site`
Then save STDOUT as {UPDATE_VERSION}
When I run `wp core update-db --network`
Then STDOUT should contain:
"""
Success: WordPress database upgraded on 3/3 sites.
"""
When I run `wp site option get wpmu_upgrade_site`
Then STDOUT should not contain:
"""
{UPDATE_VERSION}
"""
# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.0+
@require-mysql
Scenario: Update db across network, dry run
Given a WP multisite install
And a disable_sidebar_check.php file:
"""
<?php
WP_CLI::add_wp_hook( 'init', static function () {
remove_action( 'after_switch_theme', '_wp_sidebars_changed' );
} );
"""
And I try `wp theme install twentytwenty --activate`
And I run `wp core download --version=5.4 --force`
And I run `wp option update db_version 45805 --require=disable_sidebar_check.php`
And I run `wp site option update wpmu_upgrade_site 45805`
And I run `wp site create --slug=foo`
And I run `wp site create --slug=bar`
And I run `wp site create --slug=burrito --porcelain`
And save STDOUT as {BURRITO_ID}
And I run `wp site create --slug=taco --porcelain`
And save STDOUT as {TACO_ID}
And I run `wp site create --slug=pizza --porcelain`
And save STDOUT as {PIZZA_ID}
And I run `wp site archive {BURRITO_ID}`
And I run `wp site spam {TACO_ID}`
And I run `wp site delete {PIZZA_ID} --yes`
When I run `wp site option get wpmu_upgrade_site`
Then save STDOUT as {UPDATE_VERSION}
When I run `wp core update-db --network --dry-run`
Then STDOUT should contain:
"""
Performing a dry run, with no database modification.
"""
And STDOUT should contain:
"""
WordPress database will be upgraded from db version
"""
And STDOUT should not contain:
"""
WordPress database upgraded successfully from db version
"""
And STDOUT should contain:
"""
Success: WordPress database upgraded on 3/3 sites.
"""
When I run `wp site option get wpmu_upgrade_site`
Then STDOUT should contain:
"""
{UPDATE_VERSION}
"""
# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.0+
@require-mysql
Scenario: Update db respects current network in multinetwork setup
Given a WP multisite install
And a disable_sidebar_check.php file:
"""
<?php
WP_CLI::add_wp_hook( 'init', static function () {
remove_action( 'after_switch_theme', '_wp_sidebars_changed' );
} );
"""
And I try `wp theme install twentytwenty --activate`
And I run `wp core download --version=5.4 --force`
And I run `wp option update db_version 45805 --require=disable_sidebar_check.php`
And I run `wp site option update wpmu_upgrade_site 45805`
And I run `wp site create --slug=foo`
And I run `wp site create --slug=bar`
When I run `wp eval "echo defined('SITE_ID_CURRENT_SITE') ? SITE_ID_CURRENT_SITE : 'not defined';"`
Then STDOUT should contain:
"""
1
"""
When I run `wp site option get wpmu_upgrade_site`
Then save STDOUT as {UPDATE_VERSION}
When I run `wp core update-db --network`
Then STDOUT should contain:
"""
Success: WordPress database upgraded on 3/3 sites.
"""
When I run `wp site option get wpmu_upgrade_site`
Then STDOUT should not contain:
"""
{UPDATE_VERSION}
"""
Scenario: Ensure update-db sets WP_INSTALLING constant
Given a WP install
And a before.php file:
"""
<?php
WP_CLI::add_hook( 'before_invoke:core update-db', function(){
WP_CLI::log( 'WP_INSTALLING: ' . var_export( WP_INSTALLING, true ) );
});
"""
When I run `wp --require=before.php core update-db`
Then STDOUT should contain:
"""
WP_INSTALLING: true
"""