@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | ?> |
8 | 8 | <div class="wrap"> |
9 | - <h2><?php esc_html_e( 'Writing On GitHub', 'writing-on-github' ); ?></h2> |
|
9 | + <h2><?php esc_html_e('Writing On GitHub', 'writing-on-github'); ?></h2> |
|
10 | 10 | |
11 | 11 | <form method="post" action="options.php"> |
12 | - <?php settings_fields( Writing_On_GitHub::$text_domain ); ?> |
|
13 | - <?php do_settings_sections( Writing_On_GitHub::$text_domain ); ?> |
|
12 | + <?php settings_fields(Writing_On_GitHub::$text_domain); ?> |
|
13 | + <?php do_settings_sections(Writing_On_GitHub::$text_domain); ?> |
|
14 | 14 | <table class="form-table"> |
15 | 15 | <tr> |
16 | - <th scope="row"><?php esc_html_e( 'Webhook callback', 'writing-on-github' ); ?></th> |
|
17 | - <td><code><?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>?action=wogh_push_request</code></td> |
|
16 | + <th scope="row"><?php esc_html_e('Webhook callback', 'writing-on-github'); ?></th> |
|
17 | + <td><code><?php echo esc_url(admin_url('admin-ajax.php')); ?>?action=wogh_push_request</code></td> |
|
18 | 18 | </tr> |
19 | 19 | <tr> |
20 | - <th scope="row"><?php esc_html_e( 'Bulk actions', 'writing-on-github' ); ?></th> |
|
20 | + <th scope="row"><?php esc_html_e('Bulk actions', 'writing-on-github'); ?></th> |
|
21 | 21 | <td> |
22 | - <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'export' ) ) ); ?>"> |
|
23 | - <?php esc_html_e( 'Export to GitHub', 'writing-on-github' ); ?> |
|
22 | + <a href="<?php echo esc_url(add_query_arg(array('action' => 'export'))); ?>"> |
|
23 | + <?php esc_html_e('Export to GitHub', 'writing-on-github'); ?> |
|
24 | 24 | </a> | |
25 | - <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'force_export' ) ) ); ?>"> |
|
26 | - <?php esc_html_e( 'Force export to GitHub', 'writing-on-github' ); ?> |
|
25 | + <a href="<?php echo esc_url(add_query_arg(array('action' => 'force_export'))); ?>"> |
|
26 | + <?php esc_html_e('Force export to GitHub', 'writing-on-github'); ?> |
|
27 | 27 | </a> | |
28 | - <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'import' ) ) ); ?>"> |
|
29 | - <?php esc_html_e( 'Import from GitHub', 'writing-on-github' ); ?> |
|
28 | + <a href="<?php echo esc_url(add_query_arg(array('action' => 'import'))); ?>"> |
|
29 | + <?php esc_html_e('Import from GitHub', 'writing-on-github'); ?> |
|
30 | 30 | </a> |
31 | 31 | </td> |
32 | 32 | </table> |
@@ -1,8 +1,8 @@ |
||
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> |
@@ -5,6 +5,6 @@ |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | ?> |
8 | -<?php $value = get_option( $args['name'], $args['default'] ); ?> |
|
9 | -<input type="checkbox" name="<?php echo esc_attr( $args['name'] ); ?>" id="<?php echo esc_attr( $args['name'] ); ?>" value="yes" <?php echo 'yes' === $value ? 'checked' : ''; ?> /> |
|
8 | +<?php $value = get_option($args['name'], $args['default']); ?> |
|
9 | +<input type="checkbox" name="<?php echo esc_attr($args['name']); ?>" id="<?php echo esc_attr($args['name']); ?>" value="yes" <?php echo 'yes' === $value ? 'checked' : ''; ?> /> |
|
10 | 10 | <p class="description"><?php echo $args['help_text']; ?></p> |
@@ -5,6 +5,6 @@ |
||
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> |
@@ -85,69 +85,69 @@ |
||
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 |
@@ -31,10 +31,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -159,6 +159,9 @@ |
||
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 |
@@ -6,163 +6,163 @@ |
||
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 | } |
@@ -9,46 +9,46 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -4,7 +4,7 @@ discard block |
||
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 |
||
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. |
@@ -2,24 +2,24 @@ |
||
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); |