Test Failed
Push — master ( a9a295...280e7c )
by litefeel
04:06
created
tests/include/testcase.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -85,69 +85,69 @@
 block discarded – undo
85 85
 	public function setUp() {
86 86
 		parent::setUp();
87 87
 
88
-		$this->data_dir = dirname( __DIR__ ) . '/data/';
89
-
90
-		$this->app        = Mockery::mock( 'Writing_On_GitHub' );
91
-		$this->controller = Mockery::mock( 'Writing_On_GitHub_Controller' );
92
-		$this->request    = Mockery::mock( 'Writing_On_GitHub_Request' );
93
-		$this->import     = Mockery::mock( 'Writing_On_GitHub_Import' );
94
-		$this->export     = Mockery::mock( 'Writing_On_GitHub_Export' );
95
-		$this->response   = Mockery::mock( 'Writing_On_GitHub_Response' );
96
-		$this->payload    = Mockery::mock( 'Writing_On_GitHub_Payload' );
97
-		$this->api        = Mockery::mock( 'Writing_On_GitHub_Api' );
98
-		$this->semaphore  = Mockery::mock( 'Writing_On_GitHub_Semaphore' );
99
-		$this->database   = Mockery::mock( 'Writing_On_GitHub_Database' );
100
-		$this->post       = Mockery::mock( 'Writing_On_GitHub_Post' );
101
-		$this->blob       = Mockery::mock( 'Writing_On_GitHub_Blob' );
102
-		$this->api_cache  = Mockery::mock( 'Writing_On_GitHub_Cache' );
103
-		$this->fetch      = Mockery::mock( 'Writing_On_GitHub_Fetch_Client' );
104
-		$this->persist    = Mockery::mock( 'Writing_On_GitHub_Persist_Client' );
88
+		$this->data_dir = dirname(__DIR__) . '/data/';
89
+
90
+		$this->app        = Mockery::mock('Writing_On_GitHub');
91
+		$this->controller = Mockery::mock('Writing_On_GitHub_Controller');
92
+		$this->request    = Mockery::mock('Writing_On_GitHub_Request');
93
+		$this->import     = Mockery::mock('Writing_On_GitHub_Import');
94
+		$this->export     = Mockery::mock('Writing_On_GitHub_Export');
95
+		$this->response   = Mockery::mock('Writing_On_GitHub_Response');
96
+		$this->payload    = Mockery::mock('Writing_On_GitHub_Payload');
97
+		$this->api        = Mockery::mock('Writing_On_GitHub_Api');
98
+		$this->semaphore  = Mockery::mock('Writing_On_GitHub_Semaphore');
99
+		$this->database   = Mockery::mock('Writing_On_GitHub_Database');
100
+		$this->post       = Mockery::mock('Writing_On_GitHub_Post');
101
+		$this->blob       = Mockery::mock('Writing_On_GitHub_Blob');
102
+		$this->api_cache  = Mockery::mock('Writing_On_GitHub_Cache');
103
+		$this->fetch      = Mockery::mock('Writing_On_GitHub_Fetch_Client');
104
+		$this->persist    = Mockery::mock('Writing_On_GitHub_Persist_Client');
105 105
 
106 106
 		Writing_On_GitHub::$instance = $this->app;
107 107
 
108 108
 		$this->app
109
-			->shouldReceive( 'request' )
110
-			->andReturn( $this->request )
109
+			->shouldReceive('request')
110
+			->andReturn($this->request)
111 111
 			->byDefault();
112 112
 		$this->app
113
-			->shouldReceive( 'import' )
114
-			->andReturn( $this->import )
113
+			->shouldReceive('import')
114
+			->andReturn($this->import)
115 115
 			->byDefault();
116 116
 		$this->app
117
-			->shouldReceive( 'export' )
118
-			->andReturn( $this->export )
117
+			->shouldReceive('export')
118
+			->andReturn($this->export)
119 119
 			->byDefault();
120 120
 		$this->app
121
-			->shouldReceive( 'response' )
122
-			->andReturn( $this->response )
121
+			->shouldReceive('response')
122
+			->andReturn($this->response)
123 123
 			->byDefault();
124 124
 		$this->app
125
-			->shouldReceive( 'api' )
126
-			->andReturn( $this->api )
125
+			->shouldReceive('api')
126
+			->andReturn($this->api)
127 127
 			->byDefault();
128 128
 		$this->app
129
-			->shouldReceive( 'semaphore' )
130
-			->andReturn( $this->semaphore )
129
+			->shouldReceive('semaphore')
130
+			->andReturn($this->semaphore)
131 131
 			->byDefault();
132 132
 		$this->app
133
-			->shouldReceive( 'database' )
134
-			->andReturn( $this->database )
133
+			->shouldReceive('database')
134
+			->andReturn($this->database)
135 135
 			->byDefault();
136 136
 		$this->app
137
-			->shouldReceive( 'blob' )
138
-			->andReturn( $this->blob )
137
+			->shouldReceive('blob')
138
+			->andReturn($this->blob)
139 139
 			->byDefault();
140 140
 		$this->app
141
-			->shouldReceive( 'cache' )
142
-			->andReturn( $this->api_cache )
141
+			->shouldReceive('cache')
142
+			->andReturn($this->api_cache)
143 143
 			->byDefault();
144 144
 		$this->api
145
-			->shouldReceive( 'fetch' )
146
-			->andReturn( $this->fetch )
145
+			->shouldReceive('fetch')
146
+			->andReturn($this->fetch)
147 147
 			->byDefault();
148 148
 		$this->api
149
-			->shouldReceive( 'persist' )
150
-			->andReturn( $this->persist )
149
+			->shouldReceive('persist')
150
+			->andReturn($this->persist)
151 151
 			->byDefault();
152 152
 	}
153 153
 
Please login to merge, or discard this patch.
tests/unit/client/test-base.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
 		parent::setUp();
32 32
 
33 33
 		WP_HTTP_TestCase::init();
34
-		update_option( 'wogh_repository', self::REPO_OPTION_VALUE );
35
-		update_option( 'wogh_oauth_token', self::TOKEN_OPTION_VALUE );
36
-		update_option( 'wogh_host', self::HOST_OPTION_VALUE );
37
-		$this->http_responder = array( $this, 'mock_github_api' );
34
+		update_option('wogh_repository', self::REPO_OPTION_VALUE);
35
+		update_option('wogh_oauth_token', self::TOKEN_OPTION_VALUE);
36
+		update_option('wogh_host', self::HOST_OPTION_VALUE);
37
+		$this->http_responder = array($this, 'mock_github_api');
38 38
 	}
39 39
 
40 40
 	/**
@@ -43,45 +43,45 @@  discard block
 block discarded – undo
43 43
 	 *
44 44
 	 * @return void|string
45 45
 	 */
46
-	public function mock_github_api( $request, $url ) {
47
-		$host_length = strlen( self::HOST_OPTION_VALUE );
46
+	public function mock_github_api($request, $url) {
47
+		$host_length = strlen(self::HOST_OPTION_VALUE);
48 48
 
49
-		if ( self::HOST_OPTION_VALUE !== substr( $url, 0, $host_length ) ) {
50
-			$this->assertTrue( false, 'Called wrong host.' );
49
+		if (self::HOST_OPTION_VALUE !== substr($url, 0, $host_length)) {
50
+			$this->assertTrue(false, 'Called wrong host.');
51 51
 		}
52 52
 
53 53
 		if (
54
-			! isset( $request['headers']['Authorization'] ) ||
54
+			! isset($request['headers']['Authorization']) ||
55 55
 			'token ' . self::TOKEN_OPTION_VALUE !== $request['headers']['Authorization']
56 56
 		) {
57
-			$this->assertTrue( false, 'Missing authorization key.' );
57
+			$this->assertTrue(false, 'Missing authorization key.');
58 58
 		}
59 59
 
60
-		$url = explode( '/', substr( $url, $host_length + 1 ) );
60
+		$url = explode('/', substr($url, $host_length + 1));
61 61
 
62
-		if ( 'repos' !== $url[0] ) {
63
-			$this->assertTrue( false, 'Called wrong endpoint.' );
62
+		if ('repos' !== $url[0]) {
63
+			$this->assertTrue(false, 'Called wrong endpoint.');
64 64
 		}
65 65
 
66 66
 		$repo = $url[1] . '/' . $url[2];
67 67
 
68
-		if ( self::REPO_OPTION_VALUE !== $repo ) {
69
-			$this->assertTrue( false, 'Called wrong repo.' );
68
+		if (self::REPO_OPTION_VALUE !== $repo) {
69
+			$this->assertTrue(false, 'Called wrong repo.');
70 70
 		}
71 71
 
72
-		$parts = array_slice( $url, 4 );
73
-		array_unshift( $parts, strtolower( $request['method'] ) );
74
-		$endpoint = implode( '_', $parts );
75
-		$endpoint = str_replace( '?recursive=1', '', $endpoint );
76
-		$this->assertTrue( call_user_func( static::$validations[ $endpoint ], $request ), 'Request did not validate.' );
72
+		$parts = array_slice($url, 4);
73
+		array_unshift($parts, strtolower($request['method']));
74
+		$endpoint = implode('_', $parts);
75
+		$endpoint = str_replace('?recursive=1', '', $endpoint);
76
+		$this->assertTrue(call_user_func(static::$validations[$endpoint], $request), 'Request did not validate.');
77 77
 
78
-		return static::$responses[ $endpoint ];
78
+		return static::$responses[$endpoint];
79 79
 	}
80 80
 
81
-	protected function set_get_refs_heads_master( $succeed ) {
81
+	protected function set_get_refs_heads_master($succeed) {
82 82
 		$this->set_endpoint(
83
-			function ( $request ) {
84
-				if ( '[]' === $request['body'] ) {
83
+			function($request) {
84
+				if ('[]' === $request['body']) {
85 85
 					return false;
86 86
 				}
87 87
 
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
 		);
91 91
 	}
92 92
 
93
-	protected function set_get_commits( $succeed ) {
93
+	protected function set_get_commits($succeed) {
94 94
 		$this->set_endpoint(
95
-			function ( $request ) {
96
-				if ( '[]' === $request['body'] ) {
95
+			function($request) {
96
+				if ('[]' === $request['body']) {
97 97
 					return false;
98 98
 				}
99 99
 
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
 		);
103 103
 	}
104 104
 
105
-	protected function set_get_trees( $succeed, $sha = '' ) {
105
+	protected function set_get_trees($succeed, $sha = '') {
106 106
 		$this->set_endpoint(
107
-			function ( $request ) {
108
-				if ( '[]' === $request['body'] ) {
107
+			function($request) {
108
+				if ('[]' === $request['body']) {
109 109
 					return false;
110 110
 				}
111 111
 
@@ -115,17 +115,17 @@  discard block
 block discarded – undo
115 115
 		);
116 116
 	}
117 117
 
118
-	protected function set_get_blobs( $succeed ) {
118
+	protected function set_get_blobs($succeed) {
119 119
 		$shas = array(
120 120
 			'9fa5c7537f8582b71028ff34b8c20dfd0f3b2a25',
121 121
 			'8d9b2e6fd93761211dc03abd71f4a9189d680fd0',
122 122
 			'2d73165945b0ccbe4932f1363457986b0ed49f19',
123 123
 		);
124 124
 
125
-		foreach ( $shas as $sha ) {
125
+		foreach ($shas as $sha) {
126 126
 			$this->set_endpoint(
127
-				function ( $request ) {
128
-					if ( '[]' === $request['body'] ) {
127
+				function($request) {
128
+					if ('[]' === $request['body']) {
129 129
 						return false;
130 130
 					}
131 131
 
@@ -135,26 +135,26 @@  discard block
 block discarded – undo
135 135
 		}
136 136
 	}
137 137
 
138
-	protected function set_post_trees( $succeed ) {
138
+	protected function set_post_trees($succeed) {
139 139
 		$this->set_endpoint(
140
-			function ( $request ) {
141
-				$body = json_decode( $request['body'], true );
140
+			function($request) {
141
+				$body = json_decode($request['body'], true);
142 142
 
143
-				if ( ! isset( $body['tree'] ) ) {
143
+				if ( ! isset($body['tree'])) {
144 144
 					return false;
145 145
 				}
146 146
 
147
-				if ( 1 !== count( $body['tree'] ) ) {
147
+				if (1 !== count($body['tree'])) {
148 148
 					return false;
149 149
 				}
150 150
 
151
-				$blob = reset( $body['tree'] );
151
+				$blob = reset($body['tree']);
152 152
 
153 153
 				if (
154
-					! isset( $blob['path'] ) ||
155
-					! isset( $blob['type'] ) ||
156
-					! isset( $blob['content'] ) ||
157
-					! isset( $blob['mode'] )
154
+					! isset($blob['path']) ||
155
+					! isset($blob['type']) ||
156
+					! isset($blob['content']) ||
157
+					! isset($blob['mode'])
158 158
 				) {
159 159
 					return false;
160 160
 				}
@@ -166,25 +166,25 @@  discard block
 block discarded – undo
166 166
 		);
167 167
 	}
168 168
 
169
-	protected function set_post_commits( $succeed, $anonymous = true ) {
169
+	protected function set_post_commits($succeed, $anonymous = true) {
170 170
 		$this->set_endpoint(
171
-			function ( $request ) use ( $anonymous ) {
172
-				$body = json_decode( $request['body'], true );
171
+			function($request) use ($anonymous) {
172
+				$body = json_decode($request['body'], true);
173 173
 
174 174
 				if (
175
-					! isset( $body['tree'] ) ||
176
-					! isset( $body['message'] ) ||
177
-					! isset( $body['parents'] ) ||
178
-					! isset( $body['author'] )
175
+					! isset($body['tree']) ||
176
+					! isset($body['message']) ||
177
+					! isset($body['parents']) ||
178
+					! isset($body['author'])
179 179
 				) {
180 180
 					return false;
181 181
 				}
182 182
 
183
-				if ( 1 !== count( $body['parents'] ) ) {
183
+				if (1 !== count($body['parents'])) {
184 184
 					return false;
185 185
 				}
186 186
 
187
-				if ( ! $anonymous ) {
187
+				if ( ! $anonymous) {
188 188
 					if (
189 189
 						'James DiGioia' !== $body['author']['name'] ||
190 190
 						'[email protected]' !== $body['author']['email']
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
 		);
208 208
 	}
209 209
 
210
-	protected function set_patch_refs_heads_master( $succeed ) {
210
+	protected function set_patch_refs_heads_master($succeed) {
211 211
 		$this->set_endpoint(
212
-			function ( $request ) {
213
-				$body = json_decode( $request['body'], true );
212
+			function($request) {
213
+				$body = json_decode($request['body'], true);
214 214
 
215
-				if ( ! isset( $body['sha'] ) ) {
215
+				if ( ! isset($body['sha'])) {
216 216
 					return false;
217 217
 				}
218 218
 
@@ -223,18 +223,18 @@  discard block
 block discarded – undo
223 223
 		);
224 224
 	}
225 225
 
226
-	private function set_endpoint( $validation, $status, $succeed, $sha = '' ) {
227
-		list( , $caller ) = debug_backtrace( false );
228
-		$endpoint = substr( $caller['function'], 4 ) . ( $sha ? "_$sha" : '' );
226
+	private function set_endpoint($validation, $status, $succeed, $sha = '') {
227
+		list(, $caller) = debug_backtrace(false);
228
+		$endpoint = substr($caller['function'], 4) . ($sha ? "_$sha" : '');
229 229
 
230
-		static::$validations[ $endpoint ] = $validation;
230
+		static::$validations[$endpoint] = $validation;
231 231
 
232
-		static::$responses[ $endpoint ] = array(
232
+		static::$responses[$endpoint] = array(
233 233
 			'headers' => array(
234 234
 				'status' => $status,
235 235
 			),
236 236
 			'body'    => file_get_contents(
237
-				$this->data_dir . $endpoint . '_' . ( $succeed ? 'succeed' : 'fail' ) . '.json'
237
+				$this->data_dir . $endpoint . '_' . ($succeed ? 'succeed' : 'fail') . '.json'
238 238
 			),
239 239
 		);
240 240
 	}
Please login to merge, or discard this patch.
tests/unit/client/test-fetch.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -159,6 +159,9 @@
 block discarded – undo
159 159
     //  }
160 160
     // }
161 161
 
162
+    /**
163
+     * @param string $repo
164
+     */
162 165
     protected function malformed_repo( $repo ) {
163 166
         update_option( Base::REPO_OPTION_KEY, $repo );
164 167
 
Please login to merge, or discard this 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.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -9,46 +9,46 @@  discard block
 block discarded – undo
9 9
     public function setUp() {
10 10
         parent::setUp();
11 11
 
12
-        $this->fetch = new Writing_On_GitHub_Fetch_Client( $this->app );
12
+        $this->fetch = new Writing_On_GitHub_Fetch_Client($this->app);
13 13
         $this->api_cache
14
-            ->shouldReceive( 'fetch_blob' )
15
-            ->andReturn( false )
14
+            ->shouldReceive('fetch_blob')
15
+            ->andReturn(false)
16 16
             ->byDefault();
17 17
     }
18 18
 
19 19
     public function test_should_fail_if_missing_token() {
20
-        delete_option( Base::TOKEN_OPTION_KEY );
20
+        delete_option(Base::TOKEN_OPTION_KEY);
21 21
 
22
-        $this->assertInstanceOf( 'WP_Error', $error = $this->fetch->tree_recursive() );
23
-        $this->assertSame( 'missing_token', $error->get_error_code() );
22
+        $this->assertInstanceOf('WP_Error', $error = $this->fetch->tree_recursive());
23
+        $this->assertSame('missing_token', $error->get_error_code());
24 24
     }
25 25
 
26 26
     public function test_should_fail_if_missing_repo() {
27
-        delete_option( Base::REPO_OPTION_KEY );
27
+        delete_option(Base::REPO_OPTION_KEY);
28 28
 
29
-        $this->assertInstanceOf( 'WP_Error', $error = $this->fetch->tree_recursive() );
30
-        $this->assertSame( 'missing_repository', $error->get_error_code() );
29
+        $this->assertInstanceOf('WP_Error', $error = $this->fetch->tree_recursive());
30
+        $this->assertSame('missing_repository', $error->get_error_code());
31 31
     }
32 32
 
33 33
     public function test_should_fail_if_malformed_repo() {
34 34
         // If you find a particular name passing that shouldn't,
35 35
         // add it to the list here and make it pass.
36
-        $this->malformed_repo( 'repositoryname' );
36
+        $this->malformed_repo('repositoryname');
37 37
     }
38 38
 
39 39
     public function test_should_return_files_with_tree() {
40 40
         // $this->set_get_refs_heads_master( true );
41 41
         // $this->set_get_commits( true );
42
-        $this->set_get_trees( true, 'master' );
42
+        $this->set_get_trees(true, 'master');
43 43
 
44
-        $this->assertCount( 3, $this->fetch->tree_recursive() );
44
+        $this->assertCount(3, $this->fetch->tree_recursive());
45 45
     }
46 46
 
47 47
     public function test_should_fail_if_cant_fetch_tree() {
48
-        $this->set_get_trees( false, 'master' );
48
+        $this->set_get_trees(false, 'master');
49 49
 
50
-        $this->assertInstanceOf( 'WP_Error', $error = $this->fetch->tree_recursive() );
51
-        $this->assertSame( '422_unprocessable_entity', $error->get_error_code() );
50
+        $this->assertInstanceOf('WP_Error', $error = $this->fetch->tree_recursive());
51
+        $this->assertSame('422_unprocessable_entity', $error->get_error_code());
52 52
     }
53 53
 
54 54
     // public function test_should_return_commit_with_blobs_from_cache() {
@@ -72,14 +72,14 @@  discard block
 block discarded – undo
72 72
     // }
73 73
 
74 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 );
75
+        $this->set_get_trees(true, 'master');
76
+        $this->set_get_blobs(false);
77 77
 
78
-        $this->assertCount( 3, $files = $this->fetch->tree_recursive() );
78
+        $this->assertCount(3, $files = $this->fetch->tree_recursive());
79 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() );
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 83
         }
84 84
     }
85 85
 
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
     //  }
160 160
     // }
161 161
 
162
-    protected function malformed_repo( $repo ) {
163
-        update_option( Base::REPO_OPTION_KEY, $repo );
162
+    protected function malformed_repo($repo) {
163
+        update_option(Base::REPO_OPTION_KEY, $repo);
164 164
 
165
-        $this->assertInstanceOf( 'WP_Error', $error = $this->fetch->tree_recursive() );
166
-        $this->assertSame( 'malformed_repository', $error->get_error_code() );
165
+        $this->assertInstanceOf('WP_Error', $error = $this->fetch->tree_recursive());
166
+        $this->assertSame('malformed_repository', $error->get_error_code());
167 167
     }
168 168
 }
Please login to merge, or discard this patch.
writing-on-github.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
 
13 13
 // If the functions have already been autoloaded, don't reload.
14 14
 // This fixes function duplication during unit testing.
15
-if ( defined( 'WRITING_ON_GITHUB_TEST' ) && WRITING_ON_GITHUB_TEST ) {
16
-	$path = dirname( __FILE__ ) . '/vendor/autoload.php';
15
+if (defined('WRITING_ON_GITHUB_TEST') && WRITING_ON_GITHUB_TEST) {
16
+	$path = dirname(__FILE__) . '/vendor/autoload.php';
17 17
 	include_once $path;
18 18
 }
19 19
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 // require_once(dirname(__FILE__) . '/views/options.php');
42 42
 // require_once(dirname(__FILE__) . '/views/user-setting-field.php');
43 43
 
44
-add_action( 'plugins_loaded', array( new Writing_On_GitHub, 'boot' ) );
44
+add_action('plugins_loaded', array(new Writing_On_GitHub, 'boot'));
45 45
 
46 46
 class Writing_On_GitHub {
47 47
 
@@ -138,14 +138,14 @@  discard block
 block discarded – undo
138 138
 	public function __construct() {
139 139
 		self::$instance = $this;
140 140
 
141
-		if ( is_admin() ) {
141
+		if (is_admin()) {
142 142
 			$this->admin = new Writing_On_GitHub_Admin;
143 143
 		}
144 144
 
145
-		$this->controller = new Writing_On_GitHub_Controller( $this );
145
+		$this->controller = new Writing_On_GitHub_Controller($this);
146 146
 
147
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
148
-			WP_CLI::add_command( 'wogh', $this->cli() );
147
+		if (defined('WP_CLI') && WP_CLI) {
148
+			WP_CLI::add_command('wogh', $this->cli());
149 149
 		}
150 150
 	}
151 151
 
@@ -153,30 +153,30 @@  discard block
 block discarded – undo
153 153
 	 * Attaches the plugin's hooks into WordPress.
154 154
 	 */
155 155
 	public function boot() {
156
-		register_activation_hook( __FILE__, array( $this, 'activate' ) );
157
-		add_action( 'admin_notices', array( $this, 'activation_notice' ) );
156
+		register_activation_hook(__FILE__, array($this, 'activate'));
157
+		add_action('admin_notices', array($this, 'activation_notice'));
158 158
 
159
-		add_action( 'init', array( $this, 'l10n' ) );
159
+		add_action('init', array($this, 'l10n'));
160 160
 
161 161
 		// Controller actions.
162
-		add_action( 'save_post', array( $this->controller, 'export_post' ) );
163
-		add_action( 'delete_post', array( $this->controller, 'delete_post' ) );
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 );
166
-		add_action( 'wogh_import', array( $this->controller, 'import_master' ), 10, 1 );
167
-		add_filter( 'get_edit_post_link', array( $this, 'edit_post_link' ), 10, 3 );
162
+		add_action('save_post', array($this->controller, 'export_post'));
163
+		add_action('delete_post', array($this->controller, 'delete_post'));
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);
166
+		add_action('wogh_import', array($this->controller, 'import_master'), 10, 1);
167
+		add_filter('get_edit_post_link', array($this, 'edit_post_link'), 10, 3);
168 168
 
169 169
 		// add_filter( 'wogh_post_meta', array( $this, 'ignore_post_meta' ), 10, 1 );
170 170
 		// add_filter( 'wogh_pre_import_meta', array( $this, 'ignore_post_meta' ), 10, 1 );
171
-		add_filter( 'the_content', array( $this, 'the_content' ) );
171
+		add_filter('the_content', array($this, 'the_content'));
172 172
 
173
-		do_action( 'wogh_boot', $this );
173
+		do_action('wogh_boot', $this);
174 174
 	}
175 175
 
176 176
 	public function edit_post_link($link, $postID, $context) {
177
-		if ( ! wp_is_post_revision( $postID ) ) {
178
-			$post = new Writing_On_GitHub_Post( $postID, Writing_On_GitHub::$instance->api() );
179
-			if ( $post->is_on_github() ) {
177
+		if ( ! wp_is_post_revision($postID)) {
178
+			$post = new Writing_On_GitHub_Post($postID, Writing_On_GitHub::$instance->api());
179
+			if ($post->is_on_github()) {
180 180
 				return $post->github_edit_url();
181 181
 			}
182 182
 		}
@@ -235,29 +235,29 @@  discard block
 block discarded – undo
235 235
 	 * Init i18n files
236 236
 	 */
237 237
 	public function l10n() {
238
-		load_plugin_textdomain( self::$text_domain );
238
+		load_plugin_textdomain(self::$text_domain);
239 239
 	}
240 240
 
241 241
 	/**
242 242
 	 * Sets and kicks off the export cronjob
243 243
 	 */
244
-	public function start_export( $force = false ) {
245
-		$this->start_cron( 'export', $force );
244
+	public function start_export($force = false) {
245
+		$this->start_cron('export', $force);
246 246
 	}
247 247
 
248 248
 	/**
249 249
 	 * Sets and kicks off the import cronjob
250 250
 	 */
251 251
 	public function start_import() {
252
-		$this->start_cron( 'import' );
252
+		$this->start_cron('import');
253 253
 	}
254 254
 
255 255
 	/**
256 256
 	 * Enables the admin notice on initial activation
257 257
 	 */
258 258
 	public function activate() {
259
-		if ( 'yes' !== get_option( '_wogh_fully_exported' ) ) {
260
-			set_transient( '_wogh_activated', 'yes' );
259
+		if ('yes' !== get_option('_wogh_fully_exported')) {
260
+			set_transient('_wogh_activated', 'yes');
261 261
 		}
262 262
 	}
263 263
 
@@ -265,18 +265,18 @@  discard block
 block discarded – undo
265 265
 	 * Displays the activation admin notice
266 266
 	 */
267 267
 	public function activation_notice() {
268
-		if ( ! get_transient( '_wogh_activated' ) ) {
268
+		if ( ! get_transient('_wogh_activated')) {
269 269
 			return;
270 270
 		}
271 271
 
272
-		delete_transient( '_wogh_activated' );
272
+		delete_transient('_wogh_activated');
273 273
 
274 274
 		?><div class="updated">
275 275
 			<p>
276 276
 				<?php
277 277
 					printf(
278
-						__( 'To set up your site to sync with GitHub, update your <a href="%s">settings</a> and click "Export to GitHub."', 'writing-on-github' ),
279
-						admin_url( 'options-general.php?page=' . static::$text_domain)
278
+						__('To set up your site to sync with GitHub, update your <a href="%s">settings</a> and click "Export to GitHub."', 'writing-on-github'),
279
+						admin_url('options-general.php?page=' . static::$text_domain)
280 280
 					);
281 281
 				?>
282 282
 			</p>
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	 * @return Writing_On_GitHub_CLI
299 299
 	 */
300 300
 	public function cli() {
301
-		if ( ! $this->cli ) {
301
+		if ( ! $this->cli) {
302 302
 			$this->cli = new Writing_On_GitHub_CLI;
303 303
 		}
304 304
 
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
 	 * @return Writing_On_GitHub_Request
312 312
 	 */
313 313
 	public function request() {
314
-		if ( ! $this->request ) {
315
-			$this->request = new Writing_On_GitHub_Request( $this );
314
+		if ( ! $this->request) {
315
+			$this->request = new Writing_On_GitHub_Request($this);
316 316
 		}
317 317
 
318 318
 		return $this->request;
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
 	 * @return Writing_On_GitHub_Response
325 325
 	 */
326 326
 	public function response() {
327
-		if ( ! $this->response ) {
328
-			$this->response = new Writing_On_GitHub_Response( $this );
327
+		if ( ! $this->response) {
328
+			$this->response = new Writing_On_GitHub_Response($this);
329 329
 		}
330 330
 
331 331
 		return $this->response;
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
 	 * @return Writing_On_GitHub_Api
338 338
 	 */
339 339
 	public function api() {
340
-		if ( ! $this->api ) {
341
-			$this->api = new Writing_On_GitHub_Api( $this );
340
+		if ( ! $this->api) {
341
+			$this->api = new Writing_On_GitHub_Api($this);
342 342
 		}
343 343
 
344 344
 		return $this->api;
@@ -350,8 +350,8 @@  discard block
 block discarded – undo
350 350
 	 * @return Writing_On_GitHub_Import
351 351
 	 */
352 352
 	public function import() {
353
-		if ( ! $this->import ) {
354
-			$this->import = new Writing_On_GitHub_Import( $this );
353
+		if ( ! $this->import) {
354
+			$this->import = new Writing_On_GitHub_Import($this);
355 355
 		}
356 356
 
357 357
 		return $this->import;
@@ -363,8 +363,8 @@  discard block
 block discarded – undo
363 363
 	 * @return Writing_On_GitHub_Export
364 364
 	 */
365 365
 	public function export() {
366
-		if ( ! $this->export ) {
367
-			$this->export = new Writing_On_GitHub_Export( $this );
366
+		if ( ! $this->export) {
367
+			$this->export = new Writing_On_GitHub_Export($this);
368 368
 		}
369 369
 
370 370
 		return $this->export;
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	 * @return Writing_On_GitHub_Semaphore
377 377
 	 */
378 378
 	public function semaphore() {
379
-		if ( ! $this->semaphore ) {
379
+		if ( ! $this->semaphore) {
380 380
 			$this->semaphore = new Writing_On_GitHub_Semaphore;
381 381
 		}
382 382
 
@@ -389,8 +389,8 @@  discard block
 block discarded – undo
389 389
 	 * @return Writing_On_GitHub_Database
390 390
 	 */
391 391
 	public function database() {
392
-		if ( ! $this->database ) {
393
-			$this->database = new Writing_On_GitHub_Database( $this );
392
+		if ( ! $this->database) {
393
+			$this->database = new Writing_On_GitHub_Database($this);
394 394
 		}
395 395
 
396 396
 		return $this->database;
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 	 * @return Writing_On_GitHub_Cache
403 403
 	 */
404 404
 	public function cache() {
405
-		if ( ! $this->cache ) {
405
+		if ( ! $this->cache) {
406 406
 			$this->cache = new Writing_On_GitHub_Cache;
407 407
 		}
408 408
 
@@ -417,18 +417,18 @@  discard block
 block discarded – undo
417 417
 	 * @param mixed $msg
418 418
 	 * @param string $write
419 419
 	 */
420
-	public static function write_log( $msg, $write = 'line' ) {
421
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
422
-			if ( is_array( $msg ) || is_object( $msg ) ) {
423
-				WP_CLI::print_value( $msg );
420
+	public static function write_log($msg, $write = 'line') {
421
+		if (defined('WP_CLI') && WP_CLI) {
422
+			if (is_array($msg) || is_object($msg)) {
423
+				WP_CLI::print_value($msg);
424 424
 			} else {
425
-				WP_CLI::$write( $msg );
425
+				WP_CLI::$write($msg);
426 426
 			}
427
-		} elseif ( true === WP_DEBUG ) {
428
-			if ( is_array( $msg ) || is_object( $msg ) ) {
429
-				error_log( print_r( $msg, true ) );
427
+		} elseif (true === WP_DEBUG) {
428
+			if (is_array($msg) || is_object($msg)) {
429
+				error_log(print_r($msg, true));
430 430
 			} else {
431
-				error_log( $msg );
431
+				error_log($msg);
432 432
 			}
433 433
 		}
434 434
 	}
@@ -439,10 +439,10 @@  discard block
 block discarded – undo
439 439
      * @param bool   $force
440 440
      * @param string $type
441 441
      */
442
-	protected function start_cron( $type, $force = false ) {
443
-		update_option( '_wogh_' . $type . '_started', 'yes' );
442
+	protected function start_cron($type, $force = false) {
443
+		update_option('_wogh_' . $type . '_started', 'yes');
444 444
 		$user_id = get_current_user_id();
445
-		wp_schedule_single_event( time(), 'wogh_' . $type . '', array( $user_id, $force ) );
445
+		wp_schedule_single_event(time(), 'wogh_' . $type . '', array($user_id, $force));
446 446
 		spawn_cron();
447 447
 	}
448 448
 }
Please login to merge, or discard this patch.
tests/include/bootstrap.php 2 patches
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.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -2,24 +2,24 @@
 block discarded – undo
2 2
 /**
3 3
  * PHPUnit bootstrap file
4 4
  */
5
-$_tests_dir = getenv( 'WP_TESTS_DIR' );
6
-if ( ! $_tests_dir ) {
5
+$_tests_dir = getenv('WP_TESTS_DIR');
6
+if ( ! $_tests_dir) {
7 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';
11 11
 
12
-define( 'WRITING_ON_GITHUB_TEST', true );
12
+define('WRITING_ON_GITHUB_TEST', true);
13 13
 
14 14
 /**
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
-tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
21
+tests_add_filter('muplugins_loaded', '_manually_load_plugin');
22 22
 // Start up the WP testing environment.
23 23
 require $_tests_dir . '/includes/bootstrap.php';
24 24
 
25
-error_reporting( E_ALL ^ E_DEPRECATED );
25
+error_reporting(E_ALL ^ E_DEPRECATED);
Please login to merge, or discard this patch.