OSDN Git Service

fix --max_depth= again and add behat test
authorscribu <mail@scribu.net>
Sun, 26 Jan 2014 01:07:17 +0000 (03:07 +0200)
committerscribu <mail@scribu.net>
Sun, 26 Jan 2014 01:08:10 +0000 (03:08 +0200)
closes #820
see #943

features/post.feature
php/commands/post.php

index df556cc..aaec946 100644 (file)
@@ -134,4 +134,12 @@ Feature: Manage WordPress posts
       """
       Content generated by wp post generate
       """
-    And STDERR should be empty
\ No newline at end of file
+    And STDERR should be empty
+
+  Scenario: Generating pages
+    When I run `wp post generate --post_type=page --max_depth=10`
+    And I run `wp post list --post_type=page --field=post_parent`
+    Then STDOUT should contain:
+      """
+      1
+      """
index b73eef0..9cae108 100644 (file)
@@ -219,8 +219,8 @@ class Post_Command extends \WP_CLI\CommandWithDBObject {
         *     wp post list --post_type=post --posts_per_page=5 --format=json
         *
         *     wp post list --post_type=page --fields=post_title,post_status
-        * 
-        *     wp post list --post_type=page,post --format=ids 
+        *
+        *     wp post list --post_type=page,post --format=ids
         *
         * @subcommand list
         */
@@ -330,7 +330,7 @@ class Post_Command extends \WP_CLI\CommandWithDBObject {
 
                                if( $this->maybe_make_child() && $current_depth < $max_depth ) {
 
-                                       $current_parent = $post_ids[$i-1];
+                                       $current_parent = $previous_post_id;
                                        $current_depth++;
 
                                } else if( $this->maybe_reset_depth() ) {