Skip to content

Commit

Permalink
Merge pull request #30 from wp-cli/23-counter-script
Browse files Browse the repository at this point in the history
Use a helper `count-instances.php` script for cross-platform compat
  • Loading branch information
gitlost authored Dec 14, 2017
2 parents 78dbdbd + 8e3b2b8 commit b8469df
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions features/export.feature
Original file line number Diff line number Diff line change
Expand Up @@ -429,22 +429,33 @@ Feature: Export content.

Scenario: Export posts using --max_num_posts
Given a WP install
And a count-instances.php file:
"""
<?php
echo preg_match_all( '#<wp:post_type>' . $args[0] . '<\/wp:post_type>#', file_get_contents( 'php://stdin' ), $matches );
"""

When I run `wp post generate --post_type=post --count=10`
And I run `wp export --post_type=post --max_num_posts=1 --stdout | grep -cF '<wp:post_type>post</wp:post_type>'`
And I run `wp export --post_type=post --max_num_posts=1 --stdout | wp --skip-wordpress eval-file count-instances.php post`
Then STDOUT should be:
"""
1
"""

When I run `wp post generate --post_type=post --count=10`
And I run `wp post generate --post_type=attachment --count=10`
And I run `wp export --max_num_posts=1 --stdout | grep -cP '\<wp:post_type\>(attachment|post)\</wp:post_type\>'`
And I run `wp export --max_num_posts=1 --stdout | wp --skip-wordpress eval-file count-instances.php "(post|attachment)"`
Then STDOUT should be:
"""
1
"""

When I run `wp export --max_num_posts=5 --stdout | wp --skip-wordpress eval-file count-instances.php "(post|attachment)"`
Then STDOUT should be:
"""
5
"""

Scenario: Export a site with a custom filename format
Given a WP install

Expand Down

0 comments on commit b8469df

Please sign in to comment.