OSDN Git Service

replace assertStringMatchesFormat() with assertNumeric()
authorscribu <mail@scribu.net>
Mon, 12 Aug 2013 19:48:58 +0000 (22:48 +0300)
committerscribu <mail@scribu.net>
Mon, 12 Aug 2013 19:48:58 +0000 (22:48 +0300)
features/bootstrap/support.php
features/comment.feature
features/post.feature
features/site.feature
features/steps/basic_steps.php
features/term.feature
features/user.feature

index b448519..b6245af 100644 (file)
@@ -8,6 +8,12 @@ function assertEquals( $expected, $actual ) {
        }
 }
 
+function assertNumeric( $actual ) {
+       if ( !is_numeric( $actual ) ) {
+               throw new Exception( "Actual value: " . var_export( $actual ) );
+       }
+}
+
 function checkString( $output, $expected, $action ) {
        switch ( $action ) {
 
index 1641d33..8a9d250 100644 (file)
@@ -4,7 +4,7 @@ Feature: Manage WordPress comments
     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}`
index 38dfb3a..16c88c6 100644 (file)
@@ -4,7 +4,7 @@ Feature: Manage WordPress posts
     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'`
@@ -40,7 +40,7 @@ Feature: Manage WordPress posts
       """
 
     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;'`
@@ -74,10 +74,10 @@ Feature: Manage WordPress posts
     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:
index 6cdf914..aa53f8c 100644 (file)
@@ -4,7 +4,7 @@ Feature: Manage sites in a multisite installation
     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`
index 74d494b..778cb63 100644 (file)
@@ -160,9 +160,9 @@ $steps->Then( '/^(STDOUT|STDERR) should (be|contain|not contain):$/',
        }
 );
 
-$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 );
        }
 );
 
index df7dea7..97b5ad5 100644 (file)
@@ -4,7 +4,7 @@ Feature: Manage WordPress terms
     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
@@ -24,7 +24,7 @@ Feature: Manage WordPress terms
     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`
index 43bfe2a..83f3f90 100644 (file)
@@ -4,7 +4,7 @@ Feature: Manage WordPress users
     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