Test Failed
Push — ci ( 280e7c...006299 )
by litefeel
02:26
created
writing-on-github.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		add_action( 'save_post', array( $this->controller, 'export_post' ) );
163 163
 		add_action( 'delete_post', array( $this->controller, 'delete_post' ) );
164 164
 		add_action( 'wp_ajax_nopriv_wogh_push_request', array( $this->controller, 'pull_posts' ) );
165
-        add_action( 'wogh_export', array( $this->controller, 'export_all' ), 10, 2 );
165
+		add_action( 'wogh_export', array( $this->controller, 'export_all' ), 10, 2 );
166 166
 		add_action( 'wogh_import', array( $this->controller, 'import_master' ), 10, 1 );
167 167
 		add_filter( 'get_edit_post_link', array( $this, 'edit_post_link' ), 10, 3 );
168 168
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 			}
182 182
 		}
183 183
 
184
-	    return $link;
184
+		return $link;
185 185
 	}
186 186
 
187 187
 	public function ignore_post_meta($meta) {
@@ -436,9 +436,9 @@  discard block
 block discarded – undo
436 436
 	/**
437 437
 	 * Kicks of an import or export cronjob.
438 438
 	 *
439
-     * @param bool   $force
440
-     * @param string $type
441
-     */
439
+	 * @param bool   $force
440
+	 * @param string $type
441
+	 */
442 442
 	protected function start_cron( $type, $force = false ) {
443 443
 		update_option( '_wogh_' . $type . '_started', 'yes' );
444 444
 		$user_id = get_current_user_id();
Please login to merge, or discard this patch.
lib/export.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 	/**
30 30
 	 * Updates all of the current posts in the database on master.
31 31
 	 *
32
-     * @param  bool    $force_all
33
-     * @return string|WP_Error
34
-     */
32
+	 * @param  bool    $force_all
33
+	 * @return string|WP_Error
34
+	 */
35 35
 	public function full( $force_all = false ) {
36 36
 		$posts = $this->app->database()->fetch_all_supported($force_all);
37 37
 
@@ -39,24 +39,24 @@  discard block
 block discarded – undo
39 39
 			return $posts;
40 40
 		}
41 41
 
42
-        $error = false;
42
+		$error = false;
43 43
 
44
-        foreach ( $posts as $post ) {
45
-            $result = $this->update( $post->id() );
46
-            if ( is_wp_error( $result ) ) {
47
-                if ( $error ) {
48
-                    $error->add( $result->get_error_code(), $result->get_error_message() );
49
-                } else {
50
-                    $error = $result;
51
-                }
52
-            }
53
-        }
44
+		foreach ( $posts as $post ) {
45
+			$result = $this->update( $post->id() );
46
+			if ( is_wp_error( $result ) ) {
47
+				if ( $error ) {
48
+					$error->add( $result->get_error_code(), $result->get_error_message() );
49
+				} else {
50
+					$error = $result;
51
+				}
52
+			}
53
+		}
54 54
 
55
-        if ( is_wp_error( $error ) ) {
56
-            return $error;
57
-        }
55
+		if ( is_wp_error( $error ) ) {
56
+			return $error;
57
+		}
58 58
 
59
-        return __( 'Export to GitHub completed successfully.', 'writing-on-github' );
59
+		return __( 'Export to GitHub completed successfully.', 'writing-on-github' );
60 60
 	}
61 61
 
62 62
 
Please login to merge, or discard this patch.
lib/controller.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -126,10 +126,10 @@
 block discarded – undo
126 126
 	/**
127 127
 	 * Export all the posts in the database to GitHub.
128 128
 	 *
129
-     * @param  int        $user_id
130
-     * @param  boolean    $force
131
-     * @return boolean
132
-     */
129
+	 * @param  int        $user_id
130
+	 * @param  boolean    $force
131
+	 * @return boolean
132
+	 */
133 133
 	public function export_all( $user_id, $force = false ) {
134 134
 		if ( ! $this->app->semaphore()->is_open() ) {
135 135
 			return $this->app->response()->error( new WP_Error(
Please login to merge, or discard this patch.
lib/database.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 	/**
43 43
 	 * Queries the database for all of the supported posts.
44 44
 	 *
45
-     * @param  bool $force
46
-     * @return Writing_On_GitHub_Post[]|WP_Error
47
-     */
45
+	 * @param  bool $force
46
+	 * @return Writing_On_GitHub_Post[]|WP_Error
47
+	 */
48 48
 	public function fetch_all_supported( $force = false ) {
49 49
 		$args  = array(
50 50
 			'post_type'   => $this->get_whitelisted_post_types(),
@@ -187,45 +187,45 @@  discard block
 block discarded – undo
187 187
 
188 188
 		// update tags
189 189
 		if ( isset( $meta['tags'] ) && $meta['tags'] ) {
190
-		    $args['tags_input'] = $meta['tags'];
190
+			$args['tags_input'] = $meta['tags'];
191 191
 		}
192 192
 
193 193
 		// update categories
194 194
 		if ( isset( $meta['categories'] ) && $meta['categories'] ) {
195
-		    $categories = $meta['categories'];
196
-		    if (!is_array($categories)) {
197
-		        $categories = array($categories);
198
-		    }
199
-		    $terms = get_terms(array(
200
-		        'taxonomy' => 'category',
201
-		        'fields' => 'id=>name',
202
-		        'hide_empty' => 0,
203
-		        'name' => $categories
204
-		        )
205
-		    );
206
-		    $map = array();
207
-		    foreach ($categories as $name) {
208
-		        $map[$name] = 1;
209
-		    }
210
-
211
-		    $ids = array();
212
-		    if (!empty($terms)) {
213
-		        foreach ($terms as $id => $name) {
214
-		            $ids[] = $id;
215
-		            unset($map[$name]);
216
-		        }
217
-		    }
218
-
219
-		    // create new terms
220
-		    if (!empty($map)) {
221
-		        foreach ($map as $name => $value) {
222
-		            $term = wp_insert_term($name, 'category', array('parent' => 0));
223
-		            // array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
224
-		            $ids[] = $term['term_id'];
225
-		        }
226
-		    }
227
-
228
-		    $args['post_category'] = $ids;
195
+			$categories = $meta['categories'];
196
+			if (!is_array($categories)) {
197
+				$categories = array($categories);
198
+			}
199
+			$terms = get_terms(array(
200
+				'taxonomy' => 'category',
201
+				'fields' => 'id=>name',
202
+				'hide_empty' => 0,
203
+				'name' => $categories
204
+				)
205
+			);
206
+			$map = array();
207
+			foreach ($categories as $name) {
208
+				$map[$name] = 1;
209
+			}
210
+
211
+			$ids = array();
212
+			if (!empty($terms)) {
213
+				foreach ($terms as $id => $name) {
214
+					$ids[] = $id;
215
+					unset($map[$name]);
216
+				}
217
+			}
218
+
219
+			// create new terms
220
+			if (!empty($map)) {
221
+				foreach ($map as $name => $value) {
222
+					$term = wp_insert_term($name, 'category', array('parent' => 0));
223
+					// array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
224
+					$ids[] = $term['term_id'];
225
+				}
226
+			}
227
+
228
+			$args['post_category'] = $ids;
229 229
 		}
230 230
 
231 231
 		return $args;
@@ -427,12 +427,12 @@  discard block
 block discarded – undo
427 427
 		if ( ! empty( $display_name ) ) {
428 428
 			$search_string = esc_attr( $display_name );
429 429
 			$query = new WP_User_Query( array(
430
-			    'search'         => "{$search_string}",
431
-			    'search_columns' => array(
432
-			        'display_name',
433
-			        'user_nicename',
434
-			        'user_login',
435
-			    )
430
+				'search'         => "{$search_string}",
431
+				'search_columns' => array(
432
+					'display_name',
433
+					'user_nicename',
434
+					'user_login',
435
+				)
436 436
 			) );
437 437
 			$users = $query->get_results();
438 438
 			$user = empty($users) ? false : $users[0];
Please login to merge, or discard this patch.
lib/admin.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
 			)
85 85
 		);
86 86
 
87
-        register_setting( Writing_On_GitHub::$text_domain, 'wogh_ignore_author' );
88
-        add_settings_field( 'wogh_ignore_author', __( 'Ignore author', 'writing-on-github' ), array( &$this, 'checkbox_field_callback' ), Writing_On_GitHub::$text_domain, 'general', array(
89
-                'default'   => '',
90
-                'name'      => 'wogh_ignore_author',
91
-                'help_text' => __( 'Do not export author and do not use author info from GitHub.', 'writing-on-github' ),
92
-            )
93
-        );
87
+		register_setting( Writing_On_GitHub::$text_domain, 'wogh_ignore_author' );
88
+		add_settings_field( 'wogh_ignore_author', __( 'Ignore author', 'writing-on-github' ), array( &$this, 'checkbox_field_callback' ), Writing_On_GitHub::$text_domain, 'general', array(
89
+				'default'   => '',
90
+				'name'      => 'wogh_ignore_author',
91
+				'help_text' => __( 'Do not export author and do not use author info from GitHub.', 'writing-on-github' ),
92
+			)
93
+		);
94 94
 
95 95
 		// register_setting( Writing_On_GitHub::$text_domain, 'wogh_ignore_metas' );
96 96
 		// add_settings_field( 'wogh_ignore_metas', __( 'Ignore post metas', 'writing-on-github' ), array( &$this, 'textarea_field_callback' ), Writing_On_GitHub::$text_domain, 'general', array(
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
 		include dirname( dirname( __FILE__ ) ) . '/views/textarea-setting-field.php';
129 129
 	}
130 130
 
131
-    /**
132
-     * Callback to render the checkbox field.
133
-     *
134
-     * @param array $args Field arguments.
135
-     */
136
-    public function checkbox_field_callback( $args ) {
137
-        include dirname( dirname( __FILE__ ) ) . '/views/checkbox-setting-field.php';
138
-    }
131
+	/**
132
+	 * Callback to render the checkbox field.
133
+	 *
134
+	 * @param array $args Field arguments.
135
+	 */
136
+	public function checkbox_field_callback( $args ) {
137
+		include dirname( dirname( __FILE__ ) ) . '/views/checkbox-setting-field.php';
138
+	}
139 139
 
140 140
 	/**
141 141
 	 * Displays settings messages from background processes
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
 			Writing_On_GitHub::$instance->start_export();
222 222
 		}
223 223
 
224
-        if ( 'force_export' === $_GET['action'] ) {
225
-            Writing_On_GitHub::$instance->start_export(true);
226
-        }
224
+		if ( 'force_export' === $_GET['action'] ) {
225
+			Writing_On_GitHub::$instance->start_export(true);
226
+		}
227 227
 
228 228
 		if ( 'import' === $_GET['action'] ) {
229 229
 			Writing_On_GitHub::$instance->start_import();
Please login to merge, or discard this patch.
lib/blob.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -152,9 +152,9 @@
 block discarded – undo
152 152
 			array_pop( $matches );
153 153
 
154 154
 			$meta = spyc_load( $matches[2] );
155
-            if ( 'yes' == get_option('wogh_ignore_author') ) {
156
-                unset($meta['author']);
157
-            }
155
+			if ( 'yes' == get_option('wogh_ignore_author') ) {
156
+				unset($meta['author']);
157
+			}
158 158
 			// if ( isset( $meta['link'] ) ) {
159 159
 			// 	$meta['link'] = str_replace( home_url(), '', $meta['link'] );
160 160
 			// }
Please login to merge, or discard this patch.
lib/post.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -376,9 +376,9 @@
 block discarded – undo
376 376
 		if ( empty($this->post->post_excerpt) ) {
377 377
 			unset($meta['post_excerpt']);
378 378
 		}
379
-        if ( 'yes' == get_option('wogh_ignore_author') ) {
380
-            unset($meta['author']);
381
-        }
379
+		if ( 'yes' == get_option('wogh_ignore_author') ) {
380
+			unset($meta['author']);
381
+		}
382 382
 
383 383
 		//convert traditional post_meta values, hide hidden values, skip already populated values
384 384
 		// foreach ( get_post_custom( $this->id ) as $key => $value ) {
Please login to merge, or discard this patch.
tests/include/bootstrap.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  */
5 5
 $_tests_dir = getenv( 'WP_TESTS_DIR' );
6 6
 if ( ! $_tests_dir ) {
7
-    $_tests_dir = '/tmp/wordpress-tests-lib';
7
+	$_tests_dir = '/tmp/wordpress-tests-lib';
8 8
 }
9 9
 // Give access to tests_add_filter() function.
10 10
 require_once $_tests_dir . '/includes/functions.php';
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
  * Manually load the plugin being tested.
16 16
  */
17 17
 function _manually_load_plugin() {
18
-    require dirname( __FILE__ ) . '/../../writing-on-github.php';
19
-    remove_action( 'plugins_loaded', array( Writing_On_GitHub::$instance, 'boot' ) );
18
+	require dirname( __FILE__ ) . '/../../writing-on-github.php';
19
+	remove_action( 'plugins_loaded', array( Writing_On_GitHub::$instance, 'boot' ) );
20 20
 }
21 21
 tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
22 22
 // Start up the WP testing environment.
Please login to merge, or discard this patch.
tests/unit/client/test-fetch.php 1 patch
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -6,163 +6,163 @@
 block discarded – undo
6 6
  */
7 7
 class Writing_On_GitHub_Fetch_Client_Test extends Writing_On_GitHub_Base_Client_Test {
8 8
 
9
-    public function setUp() {
10
-        parent::setUp();
11
-
12
-        $this->fetch = new Writing_On_GitHub_Fetch_Client( $this->app );
13
-        $this->api_cache
14
-            ->shouldReceive( 'fetch_blob' )
15
-            ->andReturn( false )
16
-            ->byDefault();
17
-    }
18
-
19
-    public function test_should_fail_if_missing_token() {
20
-        delete_option( Base::TOKEN_OPTION_KEY );
21
-
22
-        $this->assertInstanceOf( 'WP_Error', $error = $this->fetch->tree_recursive() );
23
-        $this->assertSame( 'missing_token', $error->get_error_code() );
24
-    }
25
-
26
-    public function test_should_fail_if_missing_repo() {
27
-        delete_option( Base::REPO_OPTION_KEY );
28
-
29
-        $this->assertInstanceOf( 'WP_Error', $error = $this->fetch->tree_recursive() );
30
-        $this->assertSame( 'missing_repository', $error->get_error_code() );
31
-    }
32
-
33
-    public function test_should_fail_if_malformed_repo() {
34
-        // If you find a particular name passing that shouldn't,
35
-        // add it to the list here and make it pass.
36
-        $this->malformed_repo( 'repositoryname' );
37
-    }
38
-
39
-    public function test_should_return_files_with_tree() {
40
-        // $this->set_get_refs_heads_master( true );
41
-        // $this->set_get_commits( true );
42
-        $this->set_get_trees( true, 'master' );
43
-
44
-        $this->assertCount( 3, $this->fetch->tree_recursive() );
45
-    }
46
-
47
-    public function test_should_fail_if_cant_fetch_tree() {
48
-        $this->set_get_trees( false, 'master' );
49
-
50
-        $this->assertInstanceOf( 'WP_Error', $error = $this->fetch->tree_recursive() );
51
-        $this->assertSame( '422_unprocessable_entity', $error->get_error_code() );
52
-    }
53
-
54
-    // public function test_should_return_commit_with_blobs_from_cache() {
55
-    //  $this->set_get_trees( true, 'master' );
56
-    //  $this->set_get_blobs( true );
57
-    //  $this->api_cache
58
-    //      ->shouldReceive( 'fetch_blob' )
59
-    //      ->times( 3 )
60
-    //      ->with( Mockery::anyOf(
61
-    //          '9fa5c7537f8582b71028ff34b8c20dfd0f3b2a25',
62
-    //          '8d9b2e6fd93761211dc03abd71f4a9189d680fd0',
63
-    //          '2d73165945b0ccbe4932f1363457986b0ed49f19'
64
-    //      ) )
65
-    //      ->andReturn( $this->blob );
66
-
67
-    //  $this->assertCount( 3, $files = $this->fetch->tree_recursive() );
68
-
69
-    //  foreach ( $files as $file ) {
70
-    //      $this->assertSame( $this->blob, $this->fetch->blob( $file ) );
71
-    //  }
72
-    // }
73
-
74
-    public function test_should_return_commit_with_no_blobs_if_api_fails() {
75
-        $this->set_get_trees( true, 'master' );
76
-        $this->set_get_blobs( false );
77
-
78
-        $this->assertCount( 3, $files = $this->fetch->tree_recursive() );
79
-
80
-        foreach ( $files as $file ) {
81
-            $this->assertInstanceOf( 'WP_Error', $error = $this->fetch->blob( $file ) );
82
-            $this->assertSame( '404_not_found', $error->get_error_code() );
83
-        }
84
-    }
85
-
86
-    // public function test_should_return_and_validate_full_commit() {
87
-    //  $this->set_get_refs_heads_master( true );
88
-    //  $this->set_get_commits( true );
89
-    //  $this->set_get_trees( true );
90
-    //  $this->set_get_blobs( true );
91
-    //  $this->api_cache
92
-    //      ->shouldReceive( 'set_blob' )
93
-    //      ->times( 3 )
94
-    //      ->with(
95
-    //          Mockery::anyOf(
96
-    //              '9fa5c7537f8582b71028ff34b8c20dfd0f3b2a25',
97
-    //              '8d9b2e6fd93761211dc03abd71f4a9189d680fd0',
98
-    //              '2d73165945b0ccbe4932f1363457986b0ed49f19'
99
-    //          ),
100
-    //          Mockery::type( 'Writing_On_GitHub_Blob' )
101
-    //      )
102
-    //      ->andReturnUsing( function ( $sha, $blob ) {
103
-    //          return $blob;
104
-    //      } );
105
-    //  $this->api_cache
106
-    //      ->shouldReceive( 'set_tree' )
107
-    //      ->once()
108
-    //      ->with( '9108868e3800bec6763e51beb0d33e15036c3626', Mockery::type( 'Writing_On_GitHub_Tree' ) )
109
-    //      ->andReturnUsing( function ( $sha, $tree ) {
110
-    //          return $tree;
111
-    //      } );
112
-    //  $this->api_cache
113
-    //      ->shouldReceive( 'set_commit' )
114
-    //      ->once()
115
-    //      ->with( 'db2510854e6aeab68ead26b48328b19f4bdf926e', Mockery::type( 'Writing_On_GitHub_Commit' ) )
116
-    //      ->andReturnUsing( function ( $sha, $commit ) {
117
-    //          return $commit;
118
-    //      } );
119
-
120
-    //  $this->assertInstanceOf( 'Writing_On_GitHub_Commit', $master = $this->fetch->master() );
121
-
122
-    //  /**
123
-    //   * Validate the commit's api data mapped correctly.
124
-    //   */
125
-    //  $this->assertSame( '7497c0574b9430ff5e5521b4572b7452ea36a056', $master->sha() );
126
-    //  $this->assertSame( '[email protected]', $master->author()->email );
127
-    //  $this->assertSame( '2015-11-02T00:36:54Z', $master->author()->date );
128
-    //  $this->assertSame( '[email protected]', $master->committer()->email );
129
-    //  $this->assertSame( '2015-11-02T00:36:54Z', $master->committer()->date );
130
-    //  $this->assertSame( 'Initial full site export - wogh', $master->message() );
131
-    //  $this->assertCount( 1, $parents = $master->parents() );
132
-    //  $this->assertSame( 'db2510854e6aeab68ead26b48328b19f4bdf926e', $parents[0]->sha );
133
-
134
-    //  $this->assertInstanceOf( 'Writing_On_GitHub_Tree', $tree = $master->tree() );
135
-
136
-    //  /**
137
-    //   * Validate the tree's api data mapped correctly.
138
-    //   */
139
-    //  $this->assertSame( '9108868e3800bec6763e51beb0d33e15036c3626', $tree->sha() );
140
-
141
-    //  $this->assertCount( 3, $blobs = $tree->blobs() );
142
-
143
-    //  /**
144
-    //   * Validate the blobs' api data mapped correctly.
145
-    //   */
146
-    //  $blobs = $tree->blobs();
147
-    //  $this->assertCount( 3, $blobs );
148
-    //  foreach ( $blobs as $blob ) {
149
-    //      $this->assertTrue( in_array( $blob->sha(), array(
150
-    //          '2d73165945b0ccbe4932f1363457986b0ed49f19',
151
-    //          '8d9b2e6fd93761211dc03abd71f4a9189d680fd0',
152
-    //          '9fa5c7537f8582b71028ff34b8c20dfd0f3b2a25',
153
-    //      ) ) );
154
-    //      $this->assertTrue( in_array( $blob->path(), array(
155
-    //          '_pages/sample-page.md',
156
-    //          '_posts/2015-11-02-hello-world.md',
157
-    //          'README.md',
158
-    //      ) ) );
159
-    //  }
160
-    // }
161
-
162
-    protected function malformed_repo( $repo ) {
163
-        update_option( Base::REPO_OPTION_KEY, $repo );
164
-
165
-        $this->assertInstanceOf( 'WP_Error', $error = $this->fetch->tree_recursive() );
166
-        $this->assertSame( 'malformed_repository', $error->get_error_code() );
167
-    }
9
+	public function setUp() {
10
+		parent::setUp();
11
+
12
+		$this->fetch = new Writing_On_GitHub_Fetch_Client( $this->app );
13
+		$this->api_cache
14
+			->shouldReceive( 'fetch_blob' )
15
+			->andReturn( false )
16
+			->byDefault();
17
+	}
18
+
19
+	public function test_should_fail_if_missing_token() {
20
+		delete_option( Base::TOKEN_OPTION_KEY );
21
+
22
+		$this->assertInstanceOf( 'WP_Error', $error = $this->fetch->tree_recursive() );
23
+		$this->assertSame( 'missing_token', $error->get_error_code() );
24
+	}
25
+
26
+	public function test_should_fail_if_missing_repo() {
27
+		delete_option( Base::REPO_OPTION_KEY );
28
+
29
+		$this->assertInstanceOf( 'WP_Error', $error = $this->fetch->tree_recursive() );
30
+		$this->assertSame( 'missing_repository', $error->get_error_code() );
31
+	}
32
+
33
+	public function test_should_fail_if_malformed_repo() {
34
+		// If you find a particular name passing that shouldn't,
35
+		// add it to the list here and make it pass.
36
+		$this->malformed_repo( 'repositoryname' );
37
+	}
38
+
39
+	public function test_should_return_files_with_tree() {
40
+		// $this->set_get_refs_heads_master( true );
41
+		// $this->set_get_commits( true );
42
+		$this->set_get_trees( true, 'master' );
43
+
44
+		$this->assertCount( 3, $this->fetch->tree_recursive() );
45
+	}
46
+
47
+	public function test_should_fail_if_cant_fetch_tree() {
48
+		$this->set_get_trees( false, 'master' );
49
+
50
+		$this->assertInstanceOf( 'WP_Error', $error = $this->fetch->tree_recursive() );
51
+		$this->assertSame( '422_unprocessable_entity', $error->get_error_code() );
52
+	}
53
+
54
+	// public function test_should_return_commit_with_blobs_from_cache() {
55
+	//  $this->set_get_trees( true, 'master' );
56
+	//  $this->set_get_blobs( true );
57
+	//  $this->api_cache
58
+	//      ->shouldReceive( 'fetch_blob' )
59
+	//      ->times( 3 )
60
+	//      ->with( Mockery::anyOf(
61
+	//          '9fa5c7537f8582b71028ff34b8c20dfd0f3b2a25',
62
+	//          '8d9b2e6fd93761211dc03abd71f4a9189d680fd0',
63
+	//          '2d73165945b0ccbe4932f1363457986b0ed49f19'
64
+	//      ) )
65
+	//      ->andReturn( $this->blob );
66
+
67
+	//  $this->assertCount( 3, $files = $this->fetch->tree_recursive() );
68
+
69
+	//  foreach ( $files as $file ) {
70
+	//      $this->assertSame( $this->blob, $this->fetch->blob( $file ) );
71
+	//  }
72
+	// }
73
+
74
+	public function test_should_return_commit_with_no_blobs_if_api_fails() {
75
+		$this->set_get_trees( true, 'master' );
76
+		$this->set_get_blobs( false );
77
+
78
+		$this->assertCount( 3, $files = $this->fetch->tree_recursive() );
79
+
80
+		foreach ( $files as $file ) {
81
+			$this->assertInstanceOf( 'WP_Error', $error = $this->fetch->blob( $file ) );
82
+			$this->assertSame( '404_not_found', $error->get_error_code() );
83
+		}
84
+	}
85
+
86
+	// public function test_should_return_and_validate_full_commit() {
87
+	//  $this->set_get_refs_heads_master( true );
88
+	//  $this->set_get_commits( true );
89
+	//  $this->set_get_trees( true );
90
+	//  $this->set_get_blobs( true );
91
+	//  $this->api_cache
92
+	//      ->shouldReceive( 'set_blob' )
93
+	//      ->times( 3 )
94
+	//      ->with(
95
+	//          Mockery::anyOf(
96
+	//              '9fa5c7537f8582b71028ff34b8c20dfd0f3b2a25',
97
+	//              '8d9b2e6fd93761211dc03abd71f4a9189d680fd0',
98
+	//              '2d73165945b0ccbe4932f1363457986b0ed49f19'
99
+	//          ),
100
+	//          Mockery::type( 'Writing_On_GitHub_Blob' )
101
+	//      )
102
+	//      ->andReturnUsing( function ( $sha, $blob ) {
103
+	//          return $blob;
104
+	//      } );
105
+	//  $this->api_cache
106
+	//      ->shouldReceive( 'set_tree' )
107
+	//      ->once()
108
+	//      ->with( '9108868e3800bec6763e51beb0d33e15036c3626', Mockery::type( 'Writing_On_GitHub_Tree' ) )
109
+	//      ->andReturnUsing( function ( $sha, $tree ) {
110
+	//          return $tree;
111
+	//      } );
112
+	//  $this->api_cache
113
+	//      ->shouldReceive( 'set_commit' )
114
+	//      ->once()
115
+	//      ->with( 'db2510854e6aeab68ead26b48328b19f4bdf926e', Mockery::type( 'Writing_On_GitHub_Commit' ) )
116
+	//      ->andReturnUsing( function ( $sha, $commit ) {
117
+	//          return $commit;
118
+	//      } );
119
+
120
+	//  $this->assertInstanceOf( 'Writing_On_GitHub_Commit', $master = $this->fetch->master() );
121
+
122
+	//  /**
123
+	//   * Validate the commit's api data mapped correctly.
124
+	//   */
125
+	//  $this->assertSame( '7497c0574b9430ff5e5521b4572b7452ea36a056', $master->sha() );
126
+	//  $this->assertSame( '[email protected]', $master->author()->email );
127
+	//  $this->assertSame( '2015-11-02T00:36:54Z', $master->author()->date );
128
+	//  $this->assertSame( '[email protected]', $master->committer()->email );
129
+	//  $this->assertSame( '2015-11-02T00:36:54Z', $master->committer()->date );
130
+	//  $this->assertSame( 'Initial full site export - wogh', $master->message() );
131
+	//  $this->assertCount( 1, $parents = $master->parents() );
132
+	//  $this->assertSame( 'db2510854e6aeab68ead26b48328b19f4bdf926e', $parents[0]->sha );
133
+
134
+	//  $this->assertInstanceOf( 'Writing_On_GitHub_Tree', $tree = $master->tree() );
135
+
136
+	//  /**
137
+	//   * Validate the tree's api data mapped correctly.
138
+	//   */
139
+	//  $this->assertSame( '9108868e3800bec6763e51beb0d33e15036c3626', $tree->sha() );
140
+
141
+	//  $this->assertCount( 3, $blobs = $tree->blobs() );
142
+
143
+	//  /**
144
+	//   * Validate the blobs' api data mapped correctly.
145
+	//   */
146
+	//  $blobs = $tree->blobs();
147
+	//  $this->assertCount( 3, $blobs );
148
+	//  foreach ( $blobs as $blob ) {
149
+	//      $this->assertTrue( in_array( $blob->sha(), array(
150
+	//          '2d73165945b0ccbe4932f1363457986b0ed49f19',
151
+	//          '8d9b2e6fd93761211dc03abd71f4a9189d680fd0',
152
+	//          '9fa5c7537f8582b71028ff34b8c20dfd0f3b2a25',
153
+	//      ) ) );
154
+	//      $this->assertTrue( in_array( $blob->path(), array(
155
+	//          '_pages/sample-page.md',
156
+	//          '_posts/2015-11-02-hello-world.md',
157
+	//          'README.md',
158
+	//      ) ) );
159
+	//  }
160
+	// }
161
+
162
+	protected function malformed_repo( $repo ) {
163
+		update_option( Base::REPO_OPTION_KEY, $repo );
164
+
165
+		$this->assertInstanceOf( 'WP_Error', $error = $this->fetch->tree_recursive() );
166
+		$this->assertSame( 'malformed_repository', $error->get_error_code() );
167
+	}
168 168
 }
Please login to merge, or discard this patch.