Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions features/comment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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`
Expand Down
25 changes: 24 additions & 1 deletion features/post.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -473,4 +474,26 @@ Feature: Manage WordPress posts
Then STDOUT should contain:
"""
2005-01-24 09:52:00
"""
"""

# 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
"""
2 changes: 1 addition & 1 deletion features/site-create.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions features/site-empty.feature
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
1 change: 1 addition & 0 deletions features/site-option.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion features/user-application-password.feature
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
18 changes: 9 additions & 9 deletions src/Site_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
}

/**
Expand All @@ -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" );
}

/**
Expand Down Expand Up @@ -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" );
}
}

Expand Down Expand Up @@ -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}" );
}

/**
Expand Down