Test Failed
Push — ci ( afab81...df83b3 )
by litefeel
02:04
created
lib/payload.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 	 * @param Writing_On_GitHub $app      Application container.
30 30
 	 * @param string                $raw_data Raw request data.
31 31
 	 */
32
-	public function __construct( Writing_On_GitHub $app, $raw_data ) {
32
+	public function __construct(Writing_On_GitHub $app, $raw_data) {
33 33
 		$this->app  = $app;
34
-		$this->data = json_decode( $raw_data );
34
+		$this->data = json_decode($raw_data);
35 35
 	}
36 36
 
37 37
 	/**
@@ -41,32 +41,32 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public function should_import() {
43 43
 		// @todo how do we get this without importing the whole api object just for this?
44
-		if ( strtolower( $this->data->repository->full_name ) !== strtolower( $this->app->api()->fetch()->repository() ) ) {
44
+		if (strtolower($this->data->repository->full_name) !== strtolower($this->app->api()->fetch()->repository())) {
45 45
 			return false;
46 46
 		}
47 47
 
48 48
 		// The last term in the ref is the payload_branch name.
49
-		$refs   = explode( '/', $this->data->ref );
50
-		$payload_branch = array_pop( $refs );
49
+		$refs   = explode('/', $this->data->ref);
50
+		$payload_branch = array_pop($refs);
51 51
 
52 52
 		$branch = $this->app->api()->fetch()->branch();
53 53
 
54
-		if ( $branch !== $payload_branch ) {
54
+		if ($branch !== $payload_branch) {
55 55
 			return false;
56 56
 		}
57 57
 
58 58
 		// We add a tag to commits we push out, so we shouldn't pull them in again.
59
-		$tag = apply_filters( 'wogh_commit_msg_tag', 'wogh' );
59
+		$tag = apply_filters('wogh_commit_msg_tag', 'wogh');
60 60
 
61
-		if ( ! $tag ) {
62
-			throw new Exception( __( 'Commit message tag not set. Filter `wogh_commit_msg_tag` misconfigured.', 'writing-on-github' ) );
61
+		if ( ! $tag) {
62
+			throw new Exception(__('Commit message tag not set. Filter `wogh_commit_msg_tag` misconfigured.', 'writing-on-github'));
63 63
 		}
64 64
 
65
-		if ( $tag === substr( $this->message(), -1 * strlen( $tag ) ) ) {
65
+		if ($tag === substr($this->message(), -1 * strlen($tag))) {
66 66
 			return false;
67 67
 		}
68 68
 
69
-		if ( ! $this->get_commit_id() ) {
69
+		if ( ! $this->get_commit_id()) {
70 70
 			return false;
71 71
 		}
72 72
 
Please login to merge, or discard this patch.
lib/api.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param Writing_On_GitHub $app Application container.
37 37
 	 */
38
-	public function __construct( Writing_On_GitHub $app ) {
38
+	public function __construct(Writing_On_GitHub $app) {
39 39
 		$this->app = $app;
40 40
 	}
41 41
 
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 	 * @return Writing_On_GitHub_Fetch_Client
46 46
 	 */
47 47
 	public function fetch() {
48
-		if ( ! $this->fetch ) {
49
-			$this->fetch = new Writing_On_GitHub_Fetch_Client( $this->app );
48
+		if ( ! $this->fetch) {
49
+			$this->fetch = new Writing_On_GitHub_Fetch_Client($this->app);
50 50
 		}
51 51
 
52 52
 		return $this->fetch;
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 	 * @return Writing_On_GitHub_Persist_Client
59 59
 	 */
60 60
 	public function persist() {
61
-		if ( ! $this->persist ) {
62
-			$this->persist = new Writing_On_GitHub_Persist_Client( $this->app );
61
+		if ( ! $this->persist) {
62
+			$this->persist = new Writing_On_GitHub_Persist_Client($this->app);
63 63
 		}
64 64
 
65 65
 		return $this->persist;
Please login to merge, or discard this patch.
lib/fileinfo.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@
 block discarded – undo
6 6
  */
7 7
 class Writing_On_GitHub_File_Info {
8 8
 
9
-	public function __construct( stdClass $data ) {
9
+	public function __construct(stdClass $data) {
10 10
 		$this->sha 			= $data->sha;
11 11
 		$this->path 		= $data->path;
12
-		$this->status 		= $data->status;
12
+		$this->status = $data->status;
13 13
 	}
14 14
 
15 15
 	public $sha;
16 16
 	public $path;
17
-	public $status;  // added removed modified
17
+	public $status; // added removed modified
18 18
 }
Please login to merge, or discard this patch.
lib/semaphore.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * Clean up the old values on instantiation.
29 29
 	 */
30 30
 	public function __construct() {
31
-		delete_option( self::KEY );
31
+		delete_option(self::KEY);
32 32
 	}
33 33
 
34 34
 	/**
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @return bool
41 41
 	 */
42 42
 	public function is_open() {
43
-		if ( self::VALUE_LOCKED === get_transient( self::KEY ) ) {
43
+		if (self::VALUE_LOCKED === get_transient(self::KEY)) {
44 44
 			return false;
45 45
 		}
46 46
 
@@ -51,13 +51,13 @@  discard block
 block discarded – undo
51 51
 	 * Enables the push lock.
52 52
 	 */
53 53
 	public function lock() {
54
-		set_transient( self::KEY, self::VALUE_LOCKED, MINUTE_IN_SECONDS );
54
+		set_transient(self::KEY, self::VALUE_LOCKED, MINUTE_IN_SECONDS);
55 55
 	}
56 56
 
57 57
 	/**
58 58
 	 * Disables the push lock.
59 59
 	 */
60 60
 	public function unlock() {
61
-		set_transient( self::KEY, self::VALUE_UNLOCKED, MINUTE_IN_SECONDS );
61
+		set_transient(self::KEY, self::VALUE_UNLOCKED, MINUTE_IN_SECONDS);
62 62
 	}
63 63
 }
Please login to merge, or discard this patch.
lib/cli.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -44,28 +44,28 @@  discard block
 block discarded – undo
44 44
 	 *
45 45
 	 * @param array $args Command arguments.
46 46
 	 */
47
-	public function export( $args ) {
48
-		list( $post_id, $user_id ) = $args;
47
+	public function export($args) {
48
+		list($post_id, $user_id) = $args;
49 49
 
50
-		if ( ! is_numeric( $user_id ) ) {
51
-			WP_CLI::error( __( 'Invalid user ID', 'writing-on-github' ) );
50
+		if ( ! is_numeric($user_id)) {
51
+			WP_CLI::error(__('Invalid user ID', 'writing-on-github'));
52 52
 		}
53 53
 
54
-		$this->app->export()->set_user( $user_id );
54
+		$this->app->export()->set_user($user_id);
55 55
 
56
-		if ( 'all' === $post_id ) {
57
-			WP_CLI::line( __( 'Starting full export to GitHub.', 'writing-on-github' ) );
56
+		if ('all' === $post_id) {
57
+			WP_CLI::line(__('Starting full export to GitHub.', 'writing-on-github'));
58 58
 			$this->app->controller()->export_all();
59
-		} elseif ( is_numeric( $post_id ) ) {
59
+		} elseif (is_numeric($post_id)) {
60 60
 			WP_CLI::line(
61 61
 				sprintf(
62
-					__( 'Exporting post ID to GitHub: %d', 'writing-on-github' ),
62
+					__('Exporting post ID to GitHub: %d', 'writing-on-github'),
63 63
 					$post_id
64 64
 				)
65 65
 			);
66
-			$this->app->controller()->export_post( (int) $post_id );
66
+			$this->app->controller()->export_post((int) $post_id);
67 67
 		} else {
68
-			WP_CLI::error( __( 'Invalid post ID', 'writing-on-github' ) );
68
+			WP_CLI::error(__('Invalid post ID', 'writing-on-github'));
69 69
 		}
70 70
 	}
71 71
 
@@ -86,16 +86,16 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @param array $args Command arguments.
88 88
 	 */
89
-	public function import( $args ) {
90
-		list( $user_id ) = $args;
89
+	public function import($args) {
90
+		list($user_id) = $args;
91 91
 
92
-		if ( ! is_numeric( $user_id ) ) {
93
-			WP_CLI::error( __( 'Invalid user ID', 'writing-on-github' ) );
92
+		if ( ! is_numeric($user_id)) {
93
+			WP_CLI::error(__('Invalid user ID', 'writing-on-github'));
94 94
 		}
95 95
 
96
-		update_option( '_wogh_export_user_id', (int) $user_id );
96
+		update_option('_wogh_export_user_id', (int) $user_id);
97 97
 
98
-		WP_CLI::line( __( 'Starting import from GitHub.', 'writing-on-github' ) );
98
+		WP_CLI::line(__('Starting import from GitHub.', 'writing-on-github'));
99 99
 
100 100
 		$this->app->controller()->import_master();
101 101
 	}
@@ -119,40 +119,40 @@  discard block
 block discarded – undo
119 119
 	 * @param array $args Command arguments.
120 120
 	 * @param array $assoc_args Command associated arguments.
121 121
 	 */
122
-	public function prime( $args, $assoc_args ) {
123
-		if ( isset( $assoc_args['branch'] ) ) {
124
-			WP_CLI::line( __( 'Starting branch import.', 'writing-on-github' ) );
122
+	public function prime($args, $assoc_args) {
123
+		if (isset($assoc_args['branch'])) {
124
+			WP_CLI::line(__('Starting branch import.', 'writing-on-github'));
125 125
 
126 126
 			$commit = $this->app->api()->fetch()->master();
127 127
 
128
-			if ( is_wp_error( $commit ) ) {
128
+			if (is_wp_error($commit)) {
129 129
 				WP_CLI::error(
130 130
 					sprintf(
131
-						__( 'Failed to import and cache branch with error: %s', 'writing-on-github' ),
131
+						__('Failed to import and cache branch with error: %s', 'writing-on-github'),
132 132
 						$commit->get_error_message()
133 133
 					)
134 134
 				);
135 135
 			} else {
136 136
 				WP_CLI::success(
137 137
 					sprintf(
138
-						__( 'Successfully imported and cached commit %s from branch.', 'writing-on-github' ),
138
+						__('Successfully imported and cached commit %s from branch.', 'writing-on-github'),
139 139
 						$commit->sha()
140 140
 					)
141 141
 				);
142 142
 			}
143
-		} else if ( isset( $assoc_args['sha'] ) ) {
144
-			WP_CLI::line( 'Starting sha import.' );
143
+		} else if (isset($assoc_args['sha'])) {
144
+			WP_CLI::line('Starting sha import.');
145 145
 
146
-			$commit = $this->app->api()->fetch()->commit( $assoc_args['sha'] );
146
+			$commit = $this->app->api()->fetch()->commit($assoc_args['sha']);
147 147
 
148 148
 			WP_CLI::success(
149 149
 				sprintf(
150
-					__( 'Successfully imported and cached commit %s.', 'writing-on-github' ),
150
+					__('Successfully imported and cached commit %s.', 'writing-on-github'),
151 151
 					$commit->sha()
152 152
 				)
153 153
 			);
154 154
 		} else {
155
-			WP_CLI::error( 'Invalid fetch.' );
155
+			WP_CLI::error('Invalid fetch.');
156 156
 		}
157 157
 	}
158 158
 }
Please login to merge, or discard this patch.
views/textarea-setting-field.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@
 block discarded – undo
5 5
  */
6 6
 
7 7
 ?>
8
-<?php $value = get_option( $args['name'], $args['default'] ); ?>
9
-<textarea name="<?php echo esc_attr( $args['name'] ); ?>" id="<?php echo esc_attr( $args['name'] ); ?>" rows="10" cols="40">
10
-<?php echo esc_attr( $value ); ?>
8
+<?php $value = get_option($args['name'], $args['default']); ?>
9
+<textarea name="<?php echo esc_attr($args['name']); ?>" id="<?php echo esc_attr($args['name']); ?>" rows="10" cols="40">
10
+<?php echo esc_attr($value); ?>
11 11
 </textarea>
12 12
 <p class="description"><?php echo $args['help_text']; ?></p>
Please login to merge, or discard this patch.
views/user-setting-field.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1
-<?php $value = get_option( $args['name'], $args['default'] ); ?>
2
-<select name="<?php echo esc_attr( $args['name'] ) ?>" id="<?php echo esc_attr( $args['name'] ) ?>">
3
-	<?php foreach ( get_users() as $user ) : ?>
4
-		<option value="<?php echo esc_attr( $user->ID ); ?>"<?php echo (int) $value === $user->ID ? ' selected' : '';?>>
5
-			<?php echo esc_html( $user->display_name ); ?>
1
+<?php $value = get_option($args['name'], $args['default']); ?>
2
+<select name="<?php echo esc_attr($args['name']) ?>" id="<?php echo esc_attr($args['name']) ?>">
3
+	<?php foreach (get_users() as $user) : ?>
4
+		<option value="<?php echo esc_attr($user->ID); ?>"<?php echo (int) $value === $user->ID ? ' selected' : ''; ?>>
5
+			<?php echo esc_html($user->display_name); ?>
6 6
 		</option>
7 7
 	<?php endforeach; ?>
8 8
 </select>
Please login to merge, or discard this patch.
views/setting-field.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,6 +5,6 @@
 block discarded – undo
5 5
  */
6 6
 
7 7
 ?>
8
-<?php $value = get_option( $args['name'], $args['default'] ); ?>
9
-<input name="<?php echo esc_attr( $args['name'] ); ?>" id="<?php echo esc_attr( $args['name'] ); ?>" type="<?php echo 'wogh_secret' === $args['name'] ? 'password' : 'text'; ?>" value="<?php echo esc_attr( $value ); ?>" />
8
+<?php $value = get_option($args['name'], $args['default']); ?>
9
+<input name="<?php echo esc_attr($args['name']); ?>" id="<?php echo esc_attr($args['name']); ?>" type="<?php echo 'wogh_secret' === $args['name'] ? 'password' : 'text'; ?>" value="<?php echo esc_attr($value); ?>" />
10 10
 <p class="description"><?php echo $args['help_text']; ?></p>
Please login to merge, or discard this patch.
tests/unit/client/test-fetch.php 2 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.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -9,77 +9,77 @@  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() {
55
-		$this->set_get_trees( true, 'master' );
56
-		$this->set_get_blobs( true );
55
+		$this->set_get_trees(true, 'master');
56
+		$this->set_get_blobs(true);
57 57
 		$this->api_cache
58
-			->shouldReceive( 'fetch_blob' )
59
-			->times( 3 )
60
-			->with( Mockery::anyOf(
58
+			->shouldReceive('fetch_blob')
59
+			->times(3)
60
+			->with(Mockery::anyOf(
61 61
 				'9fa5c7537f8582b71028ff34b8c20dfd0f3b2a25',
62 62
 				'8d9b2e6fd93761211dc03abd71f4a9189d680fd0',
63 63
 				'2d73165945b0ccbe4932f1363457986b0ed49f19'
64
-			) )
65
-			->andReturn( $this->blob );
64
+			))
65
+			->andReturn($this->blob);
66 66
 
67
-		$this->assertCount( 3, $files = $this->fetch->tree_recursive() );
67
+		$this->assertCount(3, $files = $this->fetch->tree_recursive());
68 68
 
69
-		foreach ( $files as $file ) {
70
-			$this->assertSame( $this->blob, $this->fetch->blob( $file ) );
69
+		foreach ($files as $file) {
70
+			$this->assertSame($this->blob, $this->fetch->blob($file));
71 71
 		}
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.