}
}
+function assertNumeric( $actual ) {
+ if ( !is_numeric( $actual ) ) {
+ throw new Exception( "Actual value: " . var_export( $actual ) );
+ }
+}
+
function checkString( $output, $expected, $action ) {
switch ( $action ) {
Given a WP install
When I run `wp comment create --comment_post_ID=1 --comment_content='Hello' --porcelain`
- Then STDOUT should match '%d'
+ Then STDOUT should be a number
And save STDOUT as {COMMENT_ID}
When I run `wp comment exists {COMMENT_ID}`
Given a WP install
When I run `wp post create --post_title='Test post' --porcelain`
- Then STDOUT should match '%d'
+ Then STDOUT should be a number
And save STDOUT as {POST_ID}
When I run `wp post update {POST_ID} --post_title='Updated post'`
"""
When I run `bash command.sh`
- Then STDOUT should match '%d'
+ Then STDOUT should be a number
And save STDOUT as {POST_ID}
When I run `wp eval '$post_id = {POST_ID}; echo get_post( $post_id )->post_excerpt;'`
Given a WP install
When I run `wp post create --post_title='Publish post' --post_content='Publish post content' --post_status='publish' --porcelain`
- Then STDOUT should match '%d'
+ Then STDOUT should be a number
When I run `wp post create --post_title='Draft post' --post_content='Draft post content' --post_status='draft' --porcelain`
- Then STDOUT should match '%d'
+ Then STDOUT should be a number
When I run `wp post list --post_type='post' --fields=post_title,post_name,post_status --format=csv`
Then STDOUT should be CSV containing:
Given a WP multisite install
When I run `wp site create --slug=first --porcelain`
- Then STDOUT should match '%d'
+ Then STDOUT should be a number
And save STDOUT as {SITE_ID}
When I run `wp site list`
}
);
-$steps->Then( '/^(STDOUT|STDERR) should match \'([^\']+)\'$/',
- function ( $world, $stream, $format ) {
- assertStringMatchesFormat( $format, $world->result->$stream );
+$steps->Then( '/^(STDOUT|STDERR) should be a number$/',
+ function ( $world, $stream ) {
+ assertNumeric( $world->result->$stream );
}
);
Given a WP install
When I run `wp term create 'Test term' post_tag --slug=test --description='This is a test term' --porcelain`
- Then STDOUT should match '%d'
+ Then STDOUT should be a number
When I try the previous command again
Then STDERR should not be empty
Given a WP install
When I run `wp term create 'Test delete term' post_tag --slug=test-delete --description='This is a test term to be deleted' --porcelain`
- Then STDOUT should match '%d'
+ Then STDOUT should be a number
And save STDOUT as {TERM_ID}
When I run `wp term delete {TERM_ID} post_tag`
Given a WP install
When I run `wp user create testuser testuser@example.com --porcelain`
- Then STDOUT should match '%d'
+ Then STDOUT should be a number
And save STDOUT as {USER_ID}
When I try the previous command again