diff --git a/features/comment.feature b/features/comment.feature index 02b7b4e7..e5746ebb 100644 --- a/features/comment.feature +++ b/features/comment.feature @@ -158,6 +158,7 @@ Feature: Manage WordPress comments total_comments: 1 """ + @require-mysql Scenario: Approving/unapproving comments Given I run `wp comment create --comment_post_ID=1 --comment_approved=0 --porcelain` And save STDOUT as {COMMENT_ID} @@ -218,6 +219,66 @@ Feature: Manage WordPress comments """ And the return code should be 0 + # Approving an approved comment works in SQLite + @require-sqlite + Scenario: Approving/unapproving comments + Given I run `wp comment create --comment_post_ID=1 --comment_approved=0 --porcelain` + And save STDOUT as {COMMENT_ID} + + # With site url set. + When I run `wp comment approve {COMMENT_ID} --url=www.example.com` + Then STDOUT should be: + """ + Success: Approved comment {COMMENT_ID}. + """ + + When I try the previous command again + Then STDOUT should be: + """ + Success: Approved comment {COMMENT_ID}. + """ + + When I run `wp comment get --field=comment_approved {COMMENT_ID}` + Then STDOUT should be: + """ + 1 + """ + + When I run `wp comment unapprove {COMMENT_ID} --url=www.example.com` + Then STDOUT should be: + """ + Success: Unapproved comment {COMMENT_ID}. + """ + + When I run `wp comment get --field=comment_approved {COMMENT_ID}` + Then STDOUT should be: + """ + 0 + """ + + # Without site url set. + When I try `wp comment approve {COMMENT_ID}` + Then STDOUT should be: + """ + Success: Approved comment {COMMENT_ID}. + """ + And STDERR should be: + """ + Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'. + """ + And the return code should be 0 + + When I try `wp comment unapprove {COMMENT_ID}` + Then STDOUT should be: + """ + Success: Unapproved comment {COMMENT_ID}. + """ + And STDERR should be: + """ + Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'. + """ + And the return code should be 0 + Scenario: Approving/unapproving comments with multidigit comment ID Given I run `wp comment delete $(wp comment list --field=ID)` And I run `wp comment generate --count=10 --quiet` diff --git a/features/post.feature b/features/post.feature index 1498bec4..e1f4ec34 100644 --- a/features/post.feature +++ b/features/post.feature @@ -457,6 +457,7 @@ Feature: Manage WordPress posts 2005-01-24 09:52:00 """ + @require-mysql Scenario: Publishing a post and setting a date succeeds if the edit_date flag is passed. Given a WP install @@ -473,4 +474,26 @@ Feature: Manage WordPress posts Then STDOUT should contain: """ 2005-01-24 09:52:00 - """ \ No newline at end of file + """ + + # Separate test because of a known bug in the SQLite plugin. + # See https://github.com/WordPress/sqlite-database-integration/issues/52. + # Once the bug is resolved, this separate test can be removed again. + @require-sqlite + Scenario: Publishing a post and setting a date succeeds if the edit_date flag is passed. + Given a WP install + + When I run `wp post create --post_title='test' --porcelain` + Then save STDOUT as {POST_ID} + + When I run `wp post update {POST_ID} --post_date='2005-01-24T09:52:00.000Z' --post_status='publish' --edit_date=1` + Then STDOUT should contain: + """ + Success: + """ + + When I run `wp post get {POST_ID} --field=post_date` + Then STDOUT should contain: + """ + 2005-01-24T09:52:00.000Z + """ diff --git a/features/site-create.feature b/features/site-create.feature index c4cf546b..bfc9ecbc 100644 --- a/features/site-create.feature +++ b/features/site-create.feature @@ -16,7 +16,7 @@ Feature: Create a new site on a WP multisite define( 'BLOG_ID_CURRENT_SITE', 1 ); """ - When I run `wp core config {CORE_CONFIG_SETTINGS} --extra-php < extra-config` + When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --extra-php < extra-config` Then STDOUT should be: """ Success: Generated 'wp-config.php' file. diff --git a/features/site-empty.feature b/features/site-empty.feature index a55e5a90..b23938cf 100644 --- a/features/site-empty.feature +++ b/features/site-empty.feature @@ -1,5 +1,6 @@ Feature: Empty a WordPress site of its data + @require-mysql Scenario: Empty a site Given a WP installation And I run `wp option update uploads_use_yearmonth_folders 0` diff --git a/features/site-option.feature b/features/site-option.feature index de14b84a..18b4182b 100644 --- a/features/site-option.feature +++ b/features/site-option.feature @@ -127,6 +127,7 @@ Feature: Manage WordPress site options """ And the return code should be 1 + @require-mysql Scenario: Filter options by `--site_id` Given a WP multisite installation diff --git a/features/user-application-password.feature b/features/user-application-password.feature index 635a0706..eb30311f 100644 --- a/features/user-application-password.feature +++ b/features/user-application-password.feature @@ -1,6 +1,7 @@ Feature: Manage user custom fields - @less-than-php-8.0 + # SQLite requires WordPress 6.0+. + @less-than-php-8.0 @require-mysql Scenario: User application passwords are disabled for WordPress lower than 5.6 Given a WP install And I try `wp theme install twentytwenty --activate` diff --git a/src/Site_Command.php b/src/Site_Command.php index 1721a624..e78010c9 100644 --- a/src/Site_Command.php +++ b/src/Site_Command.php @@ -52,8 +52,8 @@ private function empty_comments() { wp_cache_delete( $comment_id, 'comment' ); wp_cache_delete( $comment_id, 'comment_meta' ); } - $wpdb->query( "TRUNCATE $wpdb->comments" ); - $wpdb->query( "TRUNCATE $wpdb->commentmeta" ); + $wpdb->query( "TRUNCATE TABLE $wpdb->comments" ); + $wpdb->query( "TRUNCATE TABLE $wpdb->commentmeta" ); } /** @@ -80,8 +80,8 @@ private function empty_posts() { $posts->next(); } - $wpdb->query( "TRUNCATE $wpdb->posts" ); - $wpdb->query( "TRUNCATE $wpdb->postmeta" ); + $wpdb->query( "TRUNCATE TABLE $wpdb->posts" ); + $wpdb->query( "TRUNCATE TABLE $wpdb->postmeta" ); } /** @@ -110,11 +110,11 @@ private function empty_taxonomies() { wp_cache_delete( 'get', $taxonomy ); delete_option( "{$taxonomy}_children" ); } - $wpdb->query( "TRUNCATE $wpdb->terms" ); - $wpdb->query( "TRUNCATE $wpdb->term_taxonomy" ); - $wpdb->query( "TRUNCATE $wpdb->term_relationships" ); + $wpdb->query( "TRUNCATE TABLE $wpdb->terms" ); + $wpdb->query( "TRUNCATE TABLE $wpdb->term_taxonomy" ); + $wpdb->query( "TRUNCATE TABLE $wpdb->term_relationships" ); if ( ! empty( $wpdb->termmeta ) ) { - $wpdb->query( "TRUNCATE $wpdb->termmeta" ); + $wpdb->query( "TRUNCATE TABLE $wpdb->termmeta" ); } } @@ -143,7 +143,7 @@ private function empty_links() { } // Empty the table once link related cache and term is removed. - $wpdb->query( "TRUNCATE {$wpdb->links}" ); + $wpdb->query( "TRUNCATE TABLE {$wpdb->links}" ); } /**