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
35 changes: 29 additions & 6 deletions features/post.feature
Original file line number Diff line number Diff line change
Expand Up @@ -365,18 +365,35 @@ Feature: Manage WordPress posts
| Publish post | publish-post | publish |
| Sample Page | sample-page | publish |

When I run `wp post create --post_title='old post' --post_date='2023-01-24T09:52:00.000Z'`
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 --date_query='{"before":{"year":"2024"}}'`
Then STDOUT should contain:
Scenario: List posts with date query
When I run `wp post create --post_title='old post' --post_date='2023-01-24T09:52:00.000Z'`
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 --date_query='{"before":{"year":"2024"}}'`
Then STDOUT should contain:
"""
old post
"""
And STDOUT should not contain:
"""
And STDOUT should not contain:
"""
new post
"""

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 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:
"""
post-1
"""
And STDOUT should not contain:
"""
post-2
"""

Scenario: Update categories on a post
When I run `wp term create category "Test Category" --porcelain`
Then save STDOUT as {TERM_ID}
Expand Down Expand Up @@ -427,6 +444,12 @@ Feature: Manage WordPress posts
| {POST_ID} | key2 | value2b |
| {POST_ID} | key3 | value3 |

When I run `wp post list --field=post_title --meta_query='[{"key":"key2","value":"value2b"}]'`
Then STDOUT should contain:
"""
Test Post
"""

@less-than-wp-4.4
Scenario: Creating/updating posts with meta keys for WP < 4.4 has no effect so should give warning
When I try `wp post create --post_title='Test Post' --post_content='Test post content' --meta_input='{"key1":"value1","key2":"value2"}' --porcelain`
Expand Down
2 changes: 1 addition & 1 deletion src/Post_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ public function list_( $args, $assoc_args ) {
'posts_per_page' => -1,
'post_status' => 'any',
];
$array_arguments = [ 'date_query' ];
$array_arguments = [ 'date_query', 'tax_query', 'meta_query' ];
$assoc_args = Utils\parse_shell_arrays( $assoc_args, $array_arguments );
$query_args = array_merge( $defaults, $assoc_args );
$query_args = self::process_csv_arguments_to_arrays( $query_args );
Expand Down