@@ 500-538 (lines=39) @@ | ||
497 | ||
498 | } |
|
499 | ||
500 | function test_full_sync_sends_all_options() { |
|
501 | delete_option( 'non_existant' ); |
|
502 | Modules::get_module( "options" )->set_options_whitelist( array( |
|
503 | 'my_option', |
|
504 | 'my_prefix_value', |
|
505 | 'non_existant' |
|
506 | ) ); |
|
507 | update_option( 'my_option', 'foo' ); |
|
508 | update_option( 'my_prefix_value', 'bar' ); |
|
509 | update_option( 'my_non_synced_option', 'baz' ); |
|
510 | ||
511 | $this->sender->do_sync(); |
|
512 | ||
513 | // confirm sync worked as expected |
|
514 | $this->assertEquals( 'foo', $this->server_replica_storage->get_option( 'my_option' ) ); |
|
515 | $this->assertEquals( 'bar', $this->server_replica_storage->get_option( 'my_prefix_value' ) ); |
|
516 | $this->assertEquals( null, $this->server_replica_storage->get_option( 'my_non_synced_option' ) ); |
|
517 | $this->assertEquals( null, $this->server_replica_storage->get_option( 'non_existant' ) ); |
|
518 | ||
519 | // reset the storage, check value, and do full sync - storage should be set! |
|
520 | $this->server_replica_storage->reset(); |
|
521 | ||
522 | $this->assertEquals( null, $this->server_replica_storage->get_option( 'my_option' ) ); |
|
523 | $this->assertEquals( null, $this->server_replica_storage->get_option( 'my_prefix_value' ) ); |
|
524 | $this->assertEquals( null, $this->server_replica_storage->get_option( 'non_existant' ) ); |
|
525 | ||
526 | $this->full_sync->start(); |
|
527 | $this->sender->do_full_sync(); |
|
528 | ||
529 | $synced_options_event = $this->server_event_storage->get_most_recent_event( 'jetpack_full_sync_options' ); |
|
530 | $this->assertEquals( sizeof( $synced_options_event->args ), 2, 'Size of synced options not as expected' ); |
|
531 | $this->assertEquals( 'foo', $synced_options_event->args['my_option'] ); |
|
532 | $this->assertEquals( 'bar', $synced_options_event->args['my_prefix_value'] ); |
|
533 | ||
534 | $this->assertEquals( 'foo', $this->server_replica_storage->get_option( 'my_option' ) ); |
|
535 | $this->assertEquals( 'bar', $this->server_replica_storage->get_option( 'my_prefix_value' ) ); |
|
536 | $this->assertEquals( null, $this->server_replica_storage->get_option( 'my_non_synced_option' ) ); |
|
537 | $this->assertEquals( null, $this->server_replica_storage->get_option( 'non_existant' ) ); |
|
538 | } |
|
539 | ||
540 | // to test run phpunit -c tests/php.multisite.xml --filter test_full_sync_sends_all_network_options |
|
541 | function test_full_sync_sends_all_network_options() { |
@@ 678-712 (lines=35) @@ | ||
675 | ||
676 | } |
|
677 | ||
678 | function test_full_sync_sends_all_options() { |
|
679 | delete_option( 'non_existant' ); |
|
680 | Modules::get_module( "options" )->set_options_whitelist( array( 'my_option', 'my_prefix_value', 'non_existant' ) ); |
|
681 | update_option( 'my_option', 'foo' ); |
|
682 | update_option( 'my_prefix_value', 'bar' ); |
|
683 | update_option( 'my_non_synced_option', 'baz' ); |
|
684 | ||
685 | $this->sender->do_sync(); |
|
686 | ||
687 | // confirm sync worked as expected |
|
688 | $this->assertEquals( 'foo', $this->server_replica_storage->get_option( 'my_option' ) ); |
|
689 | $this->assertEquals( 'bar', $this->server_replica_storage->get_option( 'my_prefix_value' ) ); |
|
690 | $this->assertEquals( null, $this->server_replica_storage->get_option( 'my_non_synced_option' ) ); |
|
691 | $this->assertEquals( null, $this->server_replica_storage->get_option( 'non_existant' ) ); |
|
692 | ||
693 | // reset the storage, check value, and do full sync - storage should be set! |
|
694 | $this->server_replica_storage->reset(); |
|
695 | ||
696 | $this->assertEquals( null, $this->server_replica_storage->get_option( 'my_option' ) ); |
|
697 | $this->assertEquals( null, $this->server_replica_storage->get_option( 'my_prefix_value' ) ); |
|
698 | $this->assertEquals( null, $this->server_replica_storage->get_option( 'non_existant' ) ); |
|
699 | ||
700 | $this->full_sync->start(); |
|
701 | $this->sender->do_full_sync(); |
|
702 | ||
703 | $synced_options_event = $this->server_event_storage->get_most_recent_event( 'jetpack_full_sync_options' ); |
|
704 | $this->assertEquals( sizeof( $synced_options_event->args ), 2, 'Size of synced options not as expected' ); |
|
705 | $this->assertEquals( 'foo', $synced_options_event->args['my_option'] ); |
|
706 | $this->assertEquals( 'bar', $synced_options_event->args['my_prefix_value'] ); |
|
707 | ||
708 | $this->assertEquals( 'foo', $this->server_replica_storage->get_option( 'my_option' ) ); |
|
709 | $this->assertEquals( 'bar', $this->server_replica_storage->get_option( 'my_prefix_value' ) ); |
|
710 | $this->assertEquals( null, $this->server_replica_storage->get_option( 'my_non_synced_option' ) ); |
|
711 | $this->assertEquals( null, $this->server_replica_storage->get_option( 'non_existant' ) ); |
|
712 | } |
|
713 | ||
714 | // to test run phpunit -c tests/php.multisite.xml --filter test_full_sync_sends_all_network_options |
|
715 | function test_full_sync_sends_all_network_options() { |