@@ 531-569 (lines=39) @@ | ||
528 | * |
|
529 | * @param string|null $invalid_token The invalid token to be returned in the response. Null if the tokens should be valid. |
|
530 | */ |
|
531 | private function setup_reconnect_test( $invalid_token ) { |
|
532 | switch ( $invalid_token ) { |
|
533 | case 'blog_token': |
|
534 | add_filter( |
|
535 | 'pre_http_request', |
|
536 | array( |
|
537 | $this, |
|
538 | 'intercept_validate_tokens_request_invalid_blog_token', |
|
539 | ), |
|
540 | 10, |
|
541 | 3 |
|
542 | ); |
|
543 | break; |
|
544 | case 'user_token': |
|
545 | add_filter( |
|
546 | 'pre_http_request', |
|
547 | array( |
|
548 | $this, |
|
549 | 'intercept_validate_tokens_request_invalid_user_token', |
|
550 | ), |
|
551 | 10, |
|
552 | 3 |
|
553 | ); |
|
554 | break; |
|
555 | case null: |
|
556 | add_filter( |
|
557 | 'pre_http_request', |
|
558 | array( |
|
559 | $this, |
|
560 | 'intercept_validate_tokens_request_valid_tokens', |
|
561 | ), |
|
562 | 10, |
|
563 | 3 |
|
564 | ); |
|
565 | break; |
|
566 | } |
|
567 | ||
568 | add_filter( 'jetpack_options', array( $this, 'mock_jetpack_options' ), 10, 2 ); |
|
569 | } |
|
570 | ||
571 | /** |
|
572 | * Restore the environment after the `reconnect` test has been run. |
|
@@ 576-612 (lines=37) @@ | ||
573 | * |
|
574 | * @param string|null $invalid_token The invalid token to be returned in the response. Null if the tokens should be valid. |
|
575 | */ |
|
576 | private function shutdown_reconnect_test( $invalid_token ) { |
|
577 | switch ( $invalid_token ) { |
|
578 | case 'blog_token': |
|
579 | remove_filter( |
|
580 | 'pre_http_request', |
|
581 | array( |
|
582 | $this, |
|
583 | 'intercept_validate_tokens_request_invalid_blog_token', |
|
584 | ), |
|
585 | 10 |
|
586 | ); |
|
587 | break; |
|
588 | case 'user_token': |
|
589 | remove_filter( |
|
590 | 'pre_http_request', |
|
591 | array( |
|
592 | $this, |
|
593 | 'intercept_validate_tokens_request_invalid_user_token', |
|
594 | ), |
|
595 | 10 |
|
596 | ); |
|
597 | break; |
|
598 | case null: |
|
599 | remove_filter( |
|
600 | 'pre_http_request', |
|
601 | array( |
|
602 | $this, |
|
603 | 'intercept_validate_tokens_request_valid_tokens', |
|
604 | ), |
|
605 | 10 |
|
606 | ); |
|
607 | break; |
|
608 | } |
|
609 | ||
610 | remove_filter( 'jetpack_options', array( $this, 'mock_jetpack_options' ), 10 ); |
|
611 | remove_filter( 'pre_http_request', array( $this, 'intercept_validate_tokens_request' ), 10 ); |
|
612 | } |
|
613 | ||
614 | } |
|
615 |