@@ 179-194 (lines=16) @@ | ||
176 | /** |
|
177 | * Testing the `/jetpack/v4/sync/now` endpoint. |
|
178 | */ |
|
179 | public function test_sync_now() { |
|
180 | ||
181 | // TODO add items to queue to verify response. |
|
182 | ||
183 | $user = wp_get_current_user(); |
|
184 | $user->add_cap( 'manage_options' ); |
|
185 | ||
186 | $request = new WP_REST_Request( 'POST', '/jetpack/v4/sync/now' ); |
|
187 | $request->set_header( 'Content-Type', 'application/json' ); |
|
188 | $request->set_body( '{ "queue": "sync" }' ); |
|
189 | ||
190 | $response = $this->server->dispatch( $request ); |
|
191 | $user->remove_cap( 'manage_options' ); |
|
192 | ||
193 | $this->assertEquals( 200, $response->get_status() ); |
|
194 | } |
|
195 | ||
196 | /** |
|
197 | * Testing the `/jetpack/v4/sync/checkout` endpoint. |
|
@@ 199-214 (lines=16) @@ | ||
196 | /** |
|
197 | * Testing the `/jetpack/v4/sync/checkout` endpoint. |
|
198 | */ |
|
199 | public function test_sync_checkout() { |
|
200 | ||
201 | // TODO add items to queue to verify response. |
|
202 | ||
203 | $user = wp_get_current_user(); |
|
204 | $user->add_cap( 'manage_options' ); |
|
205 | ||
206 | $request = new WP_REST_Request( 'POST', '/jetpack/v4/sync/now' ); |
|
207 | $request->set_header( 'Content-Type', 'application/json' ); |
|
208 | $request->set_body( '{ "queue": "sync", "number_of_items": 50 }' ); |
|
209 | ||
210 | $response = $this->server->dispatch( $request ); |
|
211 | $user->remove_cap( 'manage_options' ); |
|
212 | ||
213 | $this->assertEquals( 200, $response->get_status() ); |
|
214 | } |
|
215 | ||
216 | /** |
|
217 | * Testing the `/jetpack/v4/sync/unlock` endpoint. |
|
@@ 219-234 (lines=16) @@ | ||
216 | /** |
|
217 | * Testing the `/jetpack/v4/sync/unlock` endpoint. |
|
218 | */ |
|
219 | public function test_sync_unlock() { |
|
220 | ||
221 | $user = wp_get_current_user(); |
|
222 | $user->add_cap( 'manage_options' ); |
|
223 | ||
224 | $request = new WP_REST_Request( 'POST', '/jetpack/v4/sync/unlock' ); |
|
225 | $request->set_header( 'Content-Type', 'application/json' ); |
|
226 | $request->set_body( '{ "queue": "sync" }' ); |
|
227 | ||
228 | $response = $this->server->dispatch( $request ); |
|
229 | $user->remove_cap( 'manage_options' ); |
|
230 | ||
231 | $this->assertEquals( 200, $response->get_status() ); |
|
232 | $this->assertFalse( get_option( 'jpsq_sync_checkout' ) ); |
|
233 | ||
234 | } |
|
235 | ||
236 | /** |
|
237 | * Array of Sync Endpoints and method. |