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
1 change: 0 additions & 1 deletion features/comment-meta.feature
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,3 @@ Feature: Manage comment custom fields
| 1 | apple | banana |
| 1 | apple | banana |
| 1 | banana | ["apple","apple"] |

7 changes: 3 additions & 4 deletions features/menu-item.feature
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Feature: Manage WordPress menu items
Success: Deleted 1 of 1 menu items.
"""
And I run `wp menu item list sidebar-menu --format=count`
Then STDOUT should be:
And STDOUT should be:
"""
2
"""
Expand All @@ -76,7 +76,7 @@ Feature: Manage WordPress menu items
Success: Deleted 2 of 2 menu items.
"""
And I run `wp menu item list sidebar-menu --format=count`
Then STDOUT should be:
And STDOUT should be:
"""
0
"""
Expand All @@ -103,8 +103,7 @@ Feature: Manage WordPress menu items
| Child | {CHILD_ID} | {PARENT_ID} |

When I run `wp menu item delete {PARENT_ID}`

When I run `wp menu item list grandparent-test --fields=title,db_id,menu_item_parent`
And I run `wp menu item list grandparent-test --fields=title,db_id,menu_item_parent`
Then STDOUT should be a table containing rows:
| title | db_id | menu_item_parent |
| Grandparent | {GRANDPARENT_ID} | 0 |
Expand Down
4 changes: 2 additions & 2 deletions features/option-pluck-patch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,14 @@ Feature: Option commands have pluck and patch.
And I run `wp option update option_name --format=json < input.json`

When I try `wp option patch update option_name foo`
And STDERR should contain:
Then STDERR should contain:
"""
Please provide value to update.
"""
And the return code should be 1

When I run `wp option patch update option_name foo 0`
And STDOUT should be:
Then STDOUT should be:
"""
Success: Updated 'option_name' option.
"""
3 changes: 0 additions & 3 deletions features/option.feature
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ Feature: Manage WordPress options
0
"""


# JSON values
When I run `wp option set json_opt '[ 1, 2 ]' --format=json`
Then STDOUT should not be empty
Expand All @@ -120,7 +119,6 @@ Feature: Manage WordPress options
[1,2]
"""


# Reading from files
Given a value.json file:
"""
Expand Down Expand Up @@ -182,7 +180,6 @@ Feature: Manage WordPress options
| option_name | option_value | autoload |
| hello | island | on |


@require-wp-4.2
@less-than-wp-6.6
Scenario: Managed autoloaded options
Expand Down
79 changes: 39 additions & 40 deletions features/post-create-duplicate.feature
Original file line number Diff line number Diff line change
@@ -1,82 +1,81 @@
Feature: Create Duplicate WordPress post from existing posts.

Background:
Given a WP install
Given a WP install

Scenario: Generate duplicate post.
When I run `wp term create category "Test Category" --porcelain`
Then save STDOUT as {TERM_ID}
When I run `wp term create category "Test Category" --porcelain`
Then save STDOUT as {TERM_ID}

When I run `wp term create post_tag "Test Tag" --porcelain`
Then save STDOUT as {TAG_ID}
When I run `wp term create post_tag "Test Tag" --porcelain`
Then save STDOUT as {TAG_ID}

When I run `wp post create --post_title='Test Duplicate Post' --post_category={TERM_ID} --porcelain`
And save STDOUT as {POST_ID}
When I run `wp post create --post_title='Test Duplicate Post' --post_category={TERM_ID} --porcelain`
Then save STDOUT as {POST_ID}

When I run `wp post term add {POST_ID} post_tag {TAG_ID} --by=id`
Then STDOUT should contain:
When I run `wp post term add {POST_ID} post_tag {TAG_ID} --by=id`
Then STDOUT should contain:
"""
Success: Added term.
"""

When I run `wp post create --from-post={POST_ID} --porcelain`
Then STDOUT should be a number
And save STDOUT as {DUPLICATE_POST_ID}
When I run `wp post create --from-post={POST_ID} --porcelain`
Then STDOUT should be a number
And save STDOUT as {DUPLICATE_POST_ID}

When I run `wp post get {DUPLICATE_POST_ID} --field=title`
Then STDOUT should be:
"""
Test Duplicate Post
"""
When I run `wp post get {DUPLICATE_POST_ID} --field=title`
Then STDOUT should be:
"""
Test Duplicate Post
"""

When I run `wp post term list {DUPLICATE_POST_ID} category --field=term_id`
Then STDOUT should be:
When I run `wp post term list {DUPLICATE_POST_ID} category --field=term_id`
Then STDOUT should be:
"""
{TERM_ID}
"""

When I run `wp post term list {DUPLICATE_POST_ID} post_tag --field=term_id`
Then STDOUT should be:
When I run `wp post term list {DUPLICATE_POST_ID} post_tag --field=term_id`
Then STDOUT should be:
"""
{TAG_ID}
"""

@require-wp-4.4
Scenario: Generate duplicate post with post metadata.
When I run `wp post create --post_title='Test Post' --meta_input='{"key1":"value1","key2":"value2"}' --porcelain`
Then save STDOUT as {POST_ID}
When I run `wp post create --post_title='Test Post' --meta_input='{"key1":"value1","key2":"value2"}' --porcelain`
Then save STDOUT as {POST_ID}

When I run `wp post create --from-post={POST_ID} --porcelain`
Then save STDOUT as {DUPLICATE_POST_ID}
When I run `wp post create --from-post={POST_ID} --porcelain`
Then save STDOUT as {DUPLICATE_POST_ID}

When I run `wp post meta list {DUPLICATE_POST_ID} --format=table`
Then STDOUT should be a table containing rows:
When I run `wp post meta list {DUPLICATE_POST_ID} --format=table`
Then STDOUT should be a table containing rows:
| post_id | meta_key | meta_value |
| {DUPLICATE_POST_ID} | key1 | value1 |
| {DUPLICATE_POST_ID} | key2 | value2 |


Scenario: Generate duplicate page.
When I run `wp post create --post_type="page" --post_title="Test Page" --post_content="Page Content" --porcelain`
Then save STDOUT as {POST_ID}
When I run `wp post create --post_type="page" --post_title="Test Page" --post_content="Page Content" --porcelain`
Then save STDOUT as {POST_ID}

When I run `wp post create --from-post={POST_ID} --post_title="Duplicate Page" --porcelain`
Then save STDOUT as {DUPLICATE_POST_ID}
When I run `wp post create --from-post={POST_ID} --post_title="Duplicate Page" --porcelain`
Then save STDOUT as {DUPLICATE_POST_ID}

When I run `wp post list --post_type='page' --fields="title, content, type"`
Then STDOUT should be a table containing rows:
When I run `wp post list --post_type='page' --fields="title, content, type"`
Then STDOUT should be a table containing rows:
| post_title | post_content | post_type |
| Test Page | Page Content | page |
| Duplicate Page | Page Content | page |

Scenario: Change type of duplicate post.
When I run `wp post create --post_title='Test Post' --porcelain`
Then save STDOUT as {POST_ID}
When I run `wp post create --post_title='Test Post' --porcelain`
Then save STDOUT as {POST_ID}

When I run `wp post create --from-post={POST_ID} --post_type=page --porcelain`
Then save STDOUT as {DUPLICATE_POST_ID}
When I run `wp post create --from-post={POST_ID} --post_type=page --porcelain`
Then save STDOUT as {DUPLICATE_POST_ID}

When I run `wp post get {DUPLICATE_POST_ID} --fields=type`
Then STDOUT should be a table containing rows:
When I run `wp post get {DUPLICATE_POST_ID} --fields=type`
Then STDOUT should be a table containing rows:
| Field | Value |
| post_type | page |
36 changes: 22 additions & 14 deletions features/post-generate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ Feature: Generate new WordPress posts
Howdy! 3
"""
And STDERR should be empty
And I run `wp post list --field=post_name --posts_per_page=4 --orderby=ID --order=asc`

When I run `wp post list --field=post_name --posts_per_page=4 --orderby=ID --order=asc`
Then STDOUT should contain:
"""
hello-world
Expand All @@ -78,7 +79,8 @@ Feature: Generate new WordPress posts
"""
2018-07-01 00:00:00
"""
And I run `wp post list --field=post_date_gmt`

When I run `wp post list --field=post_date_gmt`
Then STDOUT should contain:
"""
2018-07-01 00:00:00
Expand All @@ -91,7 +93,8 @@ Feature: Generate new WordPress posts
"""
2018-07-02 02:21:05
"""
And I run `wp post list --field=post_date_gmt`

When I run `wp post list --field=post_date_gmt`
Then STDOUT should contain:
"""
2018-07-02 02:21:05
Expand All @@ -104,7 +107,8 @@ Feature: Generate new WordPress posts
"""
2018-07-03 00:00:00
"""
And I run `wp post list --field=post_date_gmt`

When I run `wp post list --field=post_date_gmt`
Then STDOUT should contain:
"""
2018-07-03 00:00:00
Expand All @@ -117,7 +121,8 @@ Feature: Generate new WordPress posts
"""
2018-07-04 12:34:56
"""
And I run `wp post list --field=post_date_gmt`

When I run `wp post list --field=post_date_gmt`
Then STDOUT should contain:
"""
2018-07-04 12:34:56
Expand All @@ -130,7 +135,8 @@ Feature: Generate new WordPress posts
"""
2018-07-05 17:17:17
"""
And I run `wp post list --field=post_date_gmt`

When I run `wp post list --field=post_date_gmt`
Then STDOUT should contain:
"""
2018-07-05 17:17:17
Expand All @@ -143,7 +149,8 @@ Feature: Generate new WordPress posts
"""
2018-07-06 12:12:12
"""
And I run `wp post list --field=post_date_gmt`

When I run `wp post list --field=post_date_gmt`
Then STDOUT should contain:
"""
2018-07-06 12:12:12
Expand All @@ -156,20 +163,22 @@ Feature: Generate new WordPress posts
"""
1999-12-31 00:00:00
"""
And I run `wp post list --field=post_date_gmt`

When I run `wp post list --field=post_date_gmt`
Then STDOUT should contain:
"""
2000-01-01 00:00:00
"""

Scenario: Generating posts with different post_date & post_date_gmt argument with time
Scenario: Generating posts with different post_date & post_date_gmt argument with time
When I run `wp post generate --count=1 --post_date="1999-12-31 11:11:00" --post_date_gmt="2000-01-01 02:11:00"`
And I run `wp post list --field=post_date`
Then STDOUT should contain:
"""
1999-12-31 11:11:00
"""
And I run `wp post list --field=post_date_gmt`

When I run `wp post list --field=post_date_gmt`
Then STDOUT should contain:
"""
2000-01-01 02:11:00
Expand All @@ -178,13 +187,12 @@ Feature: Generate new WordPress posts
Scenario: Generating posts when the site timezone is ahead of UTC
When I run `wp option update timezone_string "Europe/Helsinki"`
And I run `wp post delete 1 --force`

When I run `wp post list --field=post_status`
And I run `wp post list --field=post_status`
Then STDOUT should be empty

When I run `wp post generate --count=1`
And I run `wp post list --field=post_status`
Then STDOUT should be:
"""
publish
"""
"""
2 changes: 1 addition & 1 deletion features/post-meta.feature
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ Feature: Manage post custom fields
My\New\Meta
"""

Scenario: List post meta with or without single flag
Scenario: List post meta with or without single flag
Given a WP install

When I run `wp post meta add 1 apple banana`
Expand Down
17 changes: 9 additions & 8 deletions features/post.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Feature: Manage WordPress posts
And the return code should be 0

When I try `wp post exists 1000`
And STDOUT should be empty
Then STDOUT should be empty
And the return code should be 1

When I run `wp post update {POST_ID} --post_title='Updated post'`
Expand Down Expand Up @@ -69,9 +69,10 @@ Feature: Manage WordPress posts

Scenario: Setting post categories
When I run `wp term create category "First Category" --porcelain`
And save STDOUT as {TERM_ID}
And I run `wp term create category "Second Category" --porcelain`
And save STDOUT as {SECOND_TERM_ID}
Then save STDOUT as {TERM_ID}

When I run `wp term create category "Second Category" --porcelain`
Then save STDOUT as {SECOND_TERM_ID}

When I run `wp post create --post_title="Test category" --post_category="First Category" --porcelain`
Then STDOUT should be a number
Expand Down Expand Up @@ -246,7 +247,7 @@ Feature: Manage WordPress posts

When I run `EDITOR='ex -i NONE -c %s/content/bunkum -c wq' wp post edit {POST_ID}`
Then STDERR should be empty
Then STDOUT should contain:
And STDOUT should contain:
"""
Updated post {POST_ID}.
"""
Expand Down Expand Up @@ -380,9 +381,9 @@ Feature: Manage WordPress posts

Scenario: List posts with tax query
When I run `wp term create category "First Category" --porcelain`
When I run `wp term create category "Second Category" --porcelain`
When I run `wp post create --post_title='post-1' --post_category="First Category"`
When I run `wp post create --post_title='post-2' --post_category="Second Category"`
And I run `wp term create category "Second Category" --porcelain`
And I run `wp post create --post_title='post-1' --post_category="First Category"`
And I run `wp post create --post_title='post-2' --post_category="Second Category"`
And I run `wp post create --post_title='new post' --post_date='2025-01-24T09:52:00.000Z'`
And I run `wp post list --field=post_title --tax_query='[{"taxonomy":"category","field":"slug","terms":"first-category"}]'`
Then STDOUT should contain:
Expand Down
Loading
Loading