| Conditions | 1 |
| Paths | 1 |
| Total Lines | 107 |
| Code Lines | 66 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 48 | public static function generate_shared_fixtures( $factory ) |
||
| 49 | { |
||
| 50 | self::$old_current_user = get_current_user_id(); |
||
| 51 | self::$author_id = $factory->user->create(array( 'user_login' => 'canonical-author' )); |
||
| 52 | |||
| 53 | /* |
||
| 54 | * Also set in self::setUp(), but we must configure here to make sure that |
||
| 55 | * post authorship is properly attributed for fixtures. |
||
| 56 | */ |
||
| 57 | wp_set_current_user(self::$author_id); |
||
| 58 | |||
| 59 | // Already created by install defaults: |
||
| 60 | // self::factory()->term->create( array( 'taxonomy' => 'category', 'name' => 'uncategorized' ) ); |
||
| 61 | |||
| 62 | self::$post_ids[] = $factory->post->create(array( 'import_id' => 587, 'post_title' => 'post-format-test-audio', 'post_date' => '2008-06-02 00:00:00' )); |
||
| 63 | self::$post_ids[] = $post_id = $factory->post->create(array( 'post_title' => 'post-format-test-gallery', 'post_date' => '2008-06-10 00:00:00' )); |
||
| 64 | self::$post_ids[] = $factory->post->create(array( 'import_id' => 611, 'post_type' => 'attachment', 'post_title' => 'canola2', 'post_parent' => $post_id )); |
||
| 65 | |||
| 66 | self::$post_ids[] = $factory->post->create( |
||
| 67 | array( |
||
| 68 | 'post_title' => 'images-test', |
||
| 69 | 'post_date' => '2008-09-03 00:00:00', |
||
| 70 | 'post_content' => 'Page 1 <!--nextpage--> Page 2 <!--nextpage--> Page 3' |
||
| 71 | ) |
||
| 72 | ); |
||
| 73 | |||
| 74 | self::$post_ids[] = $post_id = $factory->post->create(array( 'import_id' => 149, 'post_title' => 'comment-test', 'post_date' => '2008-03-03 00:00:00' )); |
||
| 75 | self::$comment_ids = $factory->comment->create_post_comments($post_id, 15); |
||
| 76 | |||
| 77 | self::$post_ids[] = $factory->post->create(array( 'post_date' => '2008-09-05 00:00:00' )); |
||
| 78 | |||
| 79 | self::$post_ids[] = $factory->post->create(array( 'import_id' => 123 )); |
||
| 80 | self::$post_ids[] = $factory->post->create(array( 'import_id' => 1 )); |
||
| 81 | self::$post_ids[] = $factory->post->create(array( 'import_id' => 358 )); |
||
| 82 | |||
| 83 | self::$post_ids[] = $factory->post->create(array( 'post_type' => 'page', 'post_title' => 'sample-page' )); |
||
| 84 | self::$post_ids[] = $factory->post->create(array( 'post_type' => 'page', 'post_title' => 'about' )); |
||
| 85 | self::$post_ids[] = $post_id = $factory->post->create(array( 'post_type' => 'page', 'post_title' => 'parent-page' )); |
||
| 86 | self::$post_ids[] = $factory->post->create( |
||
| 87 | array( 'import_id' => 144, 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $post_id, |
||
| 88 | ) |
||
| 89 | ); |
||
| 90 | |||
| 91 | self::$post_ids[] = $parent_id = $factory->post->create( |
||
| 92 | array( |
||
| 93 | 'post_name' => 'parent', |
||
| 94 | 'post_type' => 'page', |
||
| 95 | ) |
||
| 96 | ); |
||
| 97 | self::$post_ids[] = $child_id_1 = $factory->post->create( |
||
| 98 | array( |
||
| 99 | 'post_name' => 'child1', |
||
| 100 | 'post_type' => 'page', |
||
| 101 | 'post_parent' => $parent_id, |
||
| 102 | ) |
||
| 103 | ); |
||
| 104 | self::$post_ids[] = $child_id_2 = $factory->post->create( |
||
| 105 | array( |
||
| 106 | 'post_name' => 'child2', |
||
| 107 | 'post_type' => 'page', |
||
| 108 | 'post_parent' => $parent_id, |
||
| 109 | ) |
||
| 110 | ); |
||
| 111 | self::$post_ids[] = $grandchild_id_1 = $factory->post->create( |
||
| 112 | array( |
||
| 113 | 'post_name' => 'grandchild', |
||
| 114 | 'post_type' => 'page', |
||
| 115 | 'post_parent' => $child_id_1, |
||
| 116 | ) |
||
| 117 | ); |
||
| 118 | self::$post_ids[] = $grandchild_id_2 = $factory->post->create( |
||
| 119 | array( |
||
| 120 | 'post_name' => 'grandchild', |
||
| 121 | 'post_type' => 'page', |
||
| 122 | 'post_parent' => $child_id_2, |
||
| 123 | ) |
||
| 124 | ); |
||
| 125 | |||
| 126 | $cat1 = $factory->term->create(array( 'taxonomy' => 'category', 'name' => 'parent' )); |
||
| 127 | self::$terms['/category/parent/'] = $cat1; |
||
| 128 | self::$term_ids[ $cat1 ] = 'category'; |
||
| 129 | |||
| 130 | $cat2 = $factory->term->create( |
||
| 131 | array( |
||
| 132 | 'taxonomy' => 'category', 'name' => 'child-1', 'parent' => self::$terms['/category/parent/'], |
||
| 133 | ) |
||
| 134 | ); |
||
| 135 | self::$terms['/category/parent/child-1/'] = $cat2; |
||
| 136 | self::$term_ids[ $cat2 ] = 'category'; |
||
| 137 | |||
| 138 | $cat3 = $factory->term->create( |
||
| 139 | array( |
||
| 140 | 'taxonomy' => 'category', 'name' => 'child-2', 'parent' => self::$terms['/category/parent/child-1/'], |
||
| 141 | ) |
||
| 142 | ); |
||
| 143 | self::$terms['/category/parent/child-1/child-2/'] = $cat3; |
||
| 144 | self::$term_ids[ $cat3 ] = 'category'; |
||
| 145 | |||
| 146 | $cat4 = $factory->term->create(array( 'taxonomy' => 'category', 'name' => 'cat-a' )); |
||
| 147 | self::$term_ids[ $cat4 ] = 'category'; |
||
| 148 | |||
| 149 | $cat5 = $factory->term->create(array( 'taxonomy' => 'category', 'name' => 'cat-b' )); |
||
| 150 | self::$term_ids[ $cat5 ] = 'category'; |
||
| 151 | |||
| 152 | $tag1 = $factory->term->create(array( 'name' => 'post-formats' )); |
||
| 153 | self::$term_ids[ $tag1 ] = 'post_tag'; |
||
| 154 | } |
||
| 155 | |||
| 255 |