|
@@ 219-226 (lines=8) @@
|
| 216 |
|
protected function test__blog_token_if_exists() { |
| 217 |
|
$name = __FUNCTION__; |
| 218 |
|
|
| 219 |
|
if ( ! $this->helper_is_jetpack_connected() ) { |
| 220 |
|
return self::skipped_test( |
| 221 |
|
array( |
| 222 |
|
'name' => $name, |
| 223 |
|
'short_description' => __( 'Jetpack is not connected. No blog token to check.', 'jetpack' ), |
| 224 |
|
) |
| 225 |
|
); |
| 226 |
|
} |
| 227 |
|
$blog_token = $this->helper_get_blog_token(); |
| 228 |
|
|
| 229 |
|
if ( $blog_token ) { |
|
@@ 246-253 (lines=8) @@
|
| 243 |
|
protected function test__check_if_connected() { |
| 244 |
|
$name = __FUNCTION__; |
| 245 |
|
|
| 246 |
|
if ( ! $this->helper_get_blog_token() ) { |
| 247 |
|
return self::skipped_test( |
| 248 |
|
array( |
| 249 |
|
'name' => $name, |
| 250 |
|
'short_description' => __( 'Blog token is missing.', 'jetpack' ), |
| 251 |
|
) |
| 252 |
|
); |
| 253 |
|
} |
| 254 |
|
|
| 255 |
|
if ( $this->helper_is_jetpack_connected() ) { |
| 256 |
|
$result = self::passing_test( |
|
@@ 293-300 (lines=8) @@
|
| 290 |
|
*/ |
| 291 |
|
protected function test__master_user_exists_on_site() { |
| 292 |
|
$name = __FUNCTION__; |
| 293 |
|
if ( ! $this->helper_is_jetpack_connected() ) { |
| 294 |
|
return self::skipped_test( |
| 295 |
|
array( |
| 296 |
|
'name' => $name, |
| 297 |
|
'short_description' => __( 'Jetpack is not connected. No master user to check.', 'jetpack' ), |
| 298 |
|
) |
| 299 |
|
); |
| 300 |
|
} |
| 301 |
|
if ( ! ( new Connection_Manager() )->get_connection_owner_id() && ( new Status() )->is_no_user_testing_mode() ) { |
| 302 |
|
return self::skipped_test( |
| 303 |
|
array( |
|
@@ 331-338 (lines=8) @@
|
| 328 |
|
*/ |
| 329 |
|
protected function test__master_user_can_manage_options() { |
| 330 |
|
$name = __FUNCTION__; |
| 331 |
|
if ( ! $this->helper_is_jetpack_connected() ) { |
| 332 |
|
return self::skipped_test( |
| 333 |
|
array( |
| 334 |
|
'name' => $name, |
| 335 |
|
'short_description' => __( 'Jetpack is not connected.', 'jetpack' ), |
| 336 |
|
) |
| 337 |
|
); |
| 338 |
|
} |
| 339 |
|
if ( ! ( new Connection_Manager() )->get_connection_owner_id() && ( new Status() )->is_no_user_testing_mode() ) { |
| 340 |
|
return self::skipped_test( |
| 341 |
|
array( |
|
@@ 443-450 (lines=8) @@
|
| 440 |
|
*/ |
| 441 |
|
protected function test__identity_crisis() { |
| 442 |
|
$name = __FUNCTION__; |
| 443 |
|
if ( ! $this->helper_is_jetpack_connected() ) { |
| 444 |
|
return self::skipped_test( |
| 445 |
|
array( |
| 446 |
|
'name' => $name, |
| 447 |
|
'short_description' => __( 'Jetpack is not connected.', 'jetpack' ), |
| 448 |
|
) |
| 449 |
|
); |
| 450 |
|
} |
| 451 |
|
$identity_crisis = Jetpack::check_identity_crisis(); |
| 452 |
|
|
| 453 |
|
if ( ! $identity_crisis ) { |
|
@@ 487-495 (lines=9) @@
|
| 484 |
|
$user_id = get_current_user_id() ? get_current_user_id() : $m->get_connection_owner_id(); |
| 485 |
|
|
| 486 |
|
// If no current user or blog owner, this site must be running user-less. Blog token will be validated in its own test. |
| 487 |
|
if ( ! $user_id ) { |
| 488 |
|
l( 'skip' ); |
| 489 |
|
return self::skipped_test( |
| 490 |
|
array( |
| 491 |
|
'name' => $name, |
| 492 |
|
'short_description' => __( 'There\'s no user token to be checked.', 'jetpack' ), |
| 493 |
|
) |
| 494 |
|
); |
| 495 |
|
} |
| 496 |
|
|
| 497 |
|
$validated_tokens = ( new Tokens() )->validate( $user_id ); |
| 498 |
|
|
|
@@ 596-603 (lines=8) @@
|
| 593 |
|
); |
| 594 |
|
} |
| 595 |
|
|
| 596 |
|
if ( 404 === wp_remote_retrieve_response_code( $response ) ) { |
| 597 |
|
return self::skipped_test( |
| 598 |
|
array( |
| 599 |
|
'name' => $name, |
| 600 |
|
'short_description' => __( 'The WordPress.com API returned a 404 error.', 'jetpack' ), |
| 601 |
|
) |
| 602 |
|
); |
| 603 |
|
} |
| 604 |
|
|
| 605 |
|
$result = json_decode( $body ); |
| 606 |
|
$is_connected = ! empty( $result->connected ); |