Skip to content

Commit 07bc232

Browse files
authored
Merge pull request #431 from wp-cli/fix/430-sqlite
2 parents 4218a3a + cb25bb5 commit 07bc232

File tree

7 files changed

+99
-12
lines changed

7 files changed

+99
-12
lines changed

features/comment.feature

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ Feature: Manage WordPress comments
158158
total_comments: 1
159159
"""
160160

161+
@require-mysql
161162
Scenario: Approving/unapproving comments
162163
Given I run `wp comment create --comment_post_ID=1 --comment_approved=0 --porcelain`
163164
And save STDOUT as {COMMENT_ID}
@@ -218,6 +219,66 @@ Feature: Manage WordPress comments
218219
"""
219220
And the return code should be 0
220221

222+
# Approving an approved comment works in SQLite
223+
@require-sqlite
224+
Scenario: Approving/unapproving comments
225+
Given I run `wp comment create --comment_post_ID=1 --comment_approved=0 --porcelain`
226+
And save STDOUT as {COMMENT_ID}
227+
228+
# With site url set.
229+
When I run `wp comment approve {COMMENT_ID} --url=www.example.com`
230+
Then STDOUT should be:
231+
"""
232+
Success: Approved comment {COMMENT_ID}.
233+
"""
234+
235+
When I try the previous command again
236+
Then STDOUT should be:
237+
"""
238+
Success: Approved comment {COMMENT_ID}.
239+
"""
240+
241+
When I run `wp comment get --field=comment_approved {COMMENT_ID}`
242+
Then STDOUT should be:
243+
"""
244+
1
245+
"""
246+
247+
When I run `wp comment unapprove {COMMENT_ID} --url=www.example.com`
248+
Then STDOUT should be:
249+
"""
250+
Success: Unapproved comment {COMMENT_ID}.
251+
"""
252+
253+
When I run `wp comment get --field=comment_approved {COMMENT_ID}`
254+
Then STDOUT should be:
255+
"""
256+
0
257+
"""
258+
259+
# Without site url set.
260+
When I try `wp comment approve {COMMENT_ID}`
261+
Then STDOUT should be:
262+
"""
263+
Success: Approved comment {COMMENT_ID}.
264+
"""
265+
And STDERR should be:
266+
"""
267+
Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'.
268+
"""
269+
And the return code should be 0
270+
271+
When I try `wp comment unapprove {COMMENT_ID}`
272+
Then STDOUT should be:
273+
"""
274+
Success: Unapproved comment {COMMENT_ID}.
275+
"""
276+
And STDERR should be:
277+
"""
278+
Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'.
279+
"""
280+
And the return code should be 0
281+
221282
Scenario: Approving/unapproving comments with multidigit comment ID
222283
Given I run `wp comment delete $(wp comment list --field=ID)`
223284
And I run `wp comment generate --count=10 --quiet`

features/post.feature

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ Feature: Manage WordPress posts
457457
2005-01-24 09:52:00
458458
"""
459459

460+
@require-mysql
460461
Scenario: Publishing a post and setting a date succeeds if the edit_date flag is passed.
461462
Given a WP install
462463

@@ -473,4 +474,26 @@ Feature: Manage WordPress posts
473474
Then STDOUT should contain:
474475
"""
475476
2005-01-24 09:52:00
476-
"""
477+
"""
478+
479+
# Separate test because of a known bug in the SQLite plugin.
480+
# See https://github.com/WordPress/sqlite-database-integration/issues/52.
481+
# Once the bug is resolved, this separate test can be removed again.
482+
@require-sqlite
483+
Scenario: Publishing a post and setting a date succeeds if the edit_date flag is passed.
484+
Given a WP install
485+
486+
When I run `wp post create --post_title='test' --porcelain`
487+
Then save STDOUT as {POST_ID}
488+
489+
When I run `wp post update {POST_ID} --post_date='2005-01-24T09:52:00.000Z' --post_status='publish' --edit_date=1`
490+
Then STDOUT should contain:
491+
"""
492+
Success:
493+
"""
494+
495+
When I run `wp post get {POST_ID} --field=post_date`
496+
Then STDOUT should contain:
497+
"""
498+
2005-01-24T09:52:00.000Z
499+
"""

features/site-create.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Feature: Create a new site on a WP multisite
1616
define( 'BLOG_ID_CURRENT_SITE', 1 );
1717
"""
1818

19-
When I run `wp core config {CORE_CONFIG_SETTINGS} --extra-php < extra-config`
19+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --extra-php < extra-config`
2020
Then STDOUT should be:
2121
"""
2222
Success: Generated 'wp-config.php' file.

features/site-empty.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Feature: Empty a WordPress site of its data
22

3+
@require-mysql
34
Scenario: Empty a site
45
Given a WP installation
56
And I run `wp option update uploads_use_yearmonth_folders 0`

features/site-option.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ Feature: Manage WordPress site options
127127
"""
128128
And the return code should be 1
129129
130+
@require-mysql
130131
Scenario: Filter options by `--site_id`
131132
Given a WP multisite installation
132133

features/user-application-password.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Feature: Manage user custom fields
22

3-
@less-than-php-8.0
3+
# SQLite requires WordPress 6.0+.
4+
@less-than-php-8.0 @require-mysql
45
Scenario: User application passwords are disabled for WordPress lower than 5.6
56
Given a WP install
67
And I try `wp theme install twentytwenty --activate`

src/Site_Command.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ private function empty_comments() {
5252
wp_cache_delete( $comment_id, 'comment' );
5353
wp_cache_delete( $comment_id, 'comment_meta' );
5454
}
55-
$wpdb->query( "TRUNCATE $wpdb->comments" );
56-
$wpdb->query( "TRUNCATE $wpdb->commentmeta" );
55+
$wpdb->query( "TRUNCATE TABLE $wpdb->comments" );
56+
$wpdb->query( "TRUNCATE TABLE $wpdb->commentmeta" );
5757
}
5858

5959
/**
@@ -80,8 +80,8 @@ private function empty_posts() {
8080

8181
$posts->next();
8282
}
83-
$wpdb->query( "TRUNCATE $wpdb->posts" );
84-
$wpdb->query( "TRUNCATE $wpdb->postmeta" );
83+
$wpdb->query( "TRUNCATE TABLE $wpdb->posts" );
84+
$wpdb->query( "TRUNCATE TABLE $wpdb->postmeta" );
8585
}
8686

8787
/**
@@ -110,11 +110,11 @@ private function empty_taxonomies() {
110110
wp_cache_delete( 'get', $taxonomy );
111111
delete_option( "{$taxonomy}_children" );
112112
}
113-
$wpdb->query( "TRUNCATE $wpdb->terms" );
114-
$wpdb->query( "TRUNCATE $wpdb->term_taxonomy" );
115-
$wpdb->query( "TRUNCATE $wpdb->term_relationships" );
113+
$wpdb->query( "TRUNCATE TABLE $wpdb->terms" );
114+
$wpdb->query( "TRUNCATE TABLE $wpdb->term_taxonomy" );
115+
$wpdb->query( "TRUNCATE TABLE $wpdb->term_relationships" );
116116
if ( ! empty( $wpdb->termmeta ) ) {
117-
$wpdb->query( "TRUNCATE $wpdb->termmeta" );
117+
$wpdb->query( "TRUNCATE TABLE $wpdb->termmeta" );
118118
}
119119
}
120120

@@ -143,7 +143,7 @@ private function empty_links() {
143143
}
144144

145145
// Empty the table once link related cache and term is removed.
146-
$wpdb->query( "TRUNCATE {$wpdb->links}" );
146+
$wpdb->query( "TRUNCATE TABLE {$wpdb->links}" );
147147
}
148148

149149
/**

0 commit comments

Comments
 (0)