OSDN Git Service

behat: use table in 'should be a table containing rows' step
authorscribu <mail@scribu.net>
Wed, 29 May 2013 23:46:58 +0000 (02:46 +0300)
committerscribu <mail@scribu.net>
Thu, 30 May 2013 00:46:43 +0000 (03:46 +0300)
features/post.feature
features/search-replace.feature
features/steps/basic_steps.php

index 4992247..0e0c3c1 100644 (file)
@@ -40,11 +40,9 @@ Feature: Manage WordPress posts
 
     When I run `wp post get --format=table {POST_ID}`
     Then STDOUT should be a table containing rows:
-      """
-      Field    Value
-      ID       {POST_ID}
-      post_title       Test post
-      """
+      | Field      | Value     |
+      | ID         | {POST_ID} |
+      | post_title | Test post |
 
     When I run `wp post get --format=json {POST_ID}`
     Then STDOUT should be JSON containing:
index 3cf524d..1dd40fc 100644 (file)
@@ -26,10 +26,9 @@ Feature: Do global search/replace
 
     And I run `wp search-replace {SITEURL} {SITEURL}/subdir`
     Then STDOUT should be a table containing rows:
-    """
-    Table      Column  Replacements
-    wp_posts   guid    1002
-    """
+      | Table    | Column | Replacements |
+      | wp_posts | guid   | 1002         |
+
   Scenario: Large guid search/replace where replacement does not contain search
     Given a WP install
 
@@ -41,10 +40,8 @@ Feature: Do global search/replace
 
     And I run `wp search-replace {SITEURL} http://newdomain.com`
     Then STDOUT should be a table containing rows:
-    """
-    Table      Column  Replacements
-    wp_posts   guid    1002
-    """
+      | Table    | Column | Replacements |
+      | wp_posts | guid   | 1002         |
 
   Scenario: Large guid search/replace dry run where replacement does not contain search
     Given a WP install
@@ -57,7 +54,5 @@ Feature: Do global search/replace
 
     And I run `wp search-replace --dry-run {SITEURL} http://newdomain.com`
     Then STDOUT should be a table containing rows:
-    """
-    Table      Column  Replacements
-    wp_posts   guid    1002
-    """
+      | Table    | Column | Replacements |
+      | wp_posts | guid   | 1002         |
index 3367484..747de64 100644 (file)
@@ -165,12 +165,14 @@ $steps->Then( '/^(STDOUT|STDERR) should match \'([^\']+)\'$/',
 );
 
 $steps->Then( '/^STDOUT should be a table containing rows:$/',
-       function ( $world, PyStringNode $expected ) {
+       function ( $world, TableNode $expected ) {
                $output     = $world->result->STDOUT;
                $outputRows = explode( "\n", rtrim( $output, "\n" ) );
 
-               $expected     = $world->replace_variables( (string) $expected );
-               $expectedRows = explode( "\n", rtrim( $expected, "\n" ) );
+               $expectedRows = array();
+               foreach ( $expected->getRows() as $row ) {
+                       $expectedRows[] = $world->replace_variables( implode( "\t", $row ) );
+               }
 
                // the first row is the header and must be present
                if ( $expectedRows[0] != $outputRows[0] ) {