| @@ 607-645 (lines=39) @@ | ||
| 604 | ), $this->server_replica_storage->get_metadata( 'post', $post_id, 'test_meta_array', true ) ); |
|
| 605 | } |
|
| 606 | ||
| 607 | function test_full_sync_doesnt_sends_forbiden_private_or_public_post_meta() { |
|
| 608 | $post_id = $this->factory->post->create(); |
|
| 609 | ||
| 610 | $meta_module = Modules::get_module( "meta" ); |
|
| 611 | Settings::update_settings( array( 'post_meta_whitelist' => array( 'a_public_meta' ) ) ); |
|
| 612 | ||
| 613 | // forbidden private meta |
|
| 614 | add_post_meta( $post_id, '_test_meta_key', 'foo1' ); |
|
| 615 | add_post_meta( $post_id, '_test_meta_array', array( 'foo2', 'bar' ) ); |
|
| 616 | // forbidden public meta |
|
| 617 | add_post_meta( $post_id, 'snapTW', 'foo3' ); |
|
| 618 | // ok private meta |
|
| 619 | add_post_meta( $post_id, '_wp_attachment_metadata', 'foo4' ); |
|
| 620 | // ok public meta |
|
| 621 | add_post_meta( $post_id, 'a_public_meta', 'foo5' ); |
|
| 622 | ||
| 623 | $this->sender->do_sync(); |
|
| 624 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, '_test_meta_key', true ) ); |
|
| 625 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, '_test_meta_array', true ) ); |
|
| 626 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, 'snapTW', true ) ); |
|
| 627 | $this->assertEquals( 'foo4', $this->server_replica_storage->get_metadata( 'post', $post_id, '_wp_attachment_metadata', true ) ); |
|
| 628 | $this->assertEquals( 'foo5', $this->server_replica_storage->get_metadata( 'post', $post_id, 'a_public_meta', true ) ); |
|
| 629 | // reset the storage, check value, and do full sync - storage should be set! |
|
| 630 | $this->server_replica_storage->reset(); |
|
| 631 | ||
| 632 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, '_test_meta_key', true ) ); |
|
| 633 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, '_test_meta_array', true ) ); |
|
| 634 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, 'snapTW', true ) ); |
|
| 635 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, '_wp_attachment_metadata', true ) ); |
|
| 636 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, 'a_public_meta', true ) ); |
|
| 637 | ||
| 638 | $this->full_sync->start(); |
|
| 639 | $this->sender->do_full_sync(); |
|
| 640 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, '_test_meta_key', true ) ); |
|
| 641 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, '_test_meta_array', true ) ); |
|
| 642 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, 'snapTW', true ) ); |
|
| 643 | $this->assertEquals( 'foo4', $this->server_replica_storage->get_metadata( 'post', $post_id, '_wp_attachment_metadata', true ) ); |
|
| 644 | $this->assertEquals( 'foo5', $this->server_replica_storage->get_metadata( 'post', $post_id, 'a_public_meta', true ) ); |
|
| 645 | } |
|
| 646 | ||
| 647 | function test_full_sync_sends_all_post_terms() { |
|
| 648 | $post_id = $this->factory->post->create(); |
|
| @@ 775-813 (lines=39) @@ | ||
| 772 | $this->assertEquals( array( 'foo', 'bar' ), $this->server_replica_storage->get_metadata( 'post', $post_id, 'test_meta_array', true ) ); |
|
| 773 | } |
|
| 774 | ||
| 775 | function test_full_sync_doesnt_sends_forbiden_private_or_public_post_meta() { |
|
| 776 | $post_id = $this->factory->post->create(); |
|
| 777 | ||
| 778 | $meta_module = Modules::get_module( "meta" ); |
|
| 779 | Settings::update_settings( array( 'post_meta_whitelist' => array( 'a_public_meta' ) ) ); |
|
| 780 | ||
| 781 | // forbidden private meta |
|
| 782 | add_post_meta( $post_id, '_test_meta_key', 'foo1' ); |
|
| 783 | add_post_meta( $post_id, '_test_meta_array', array( 'foo2', 'bar' ) ); |
|
| 784 | // forbidden public meta |
|
| 785 | add_post_meta( $post_id, 'snapTW', 'foo3' ); |
|
| 786 | // ok private meta |
|
| 787 | add_post_meta( $post_id, '_wp_attachment_metadata', 'foo4' ); |
|
| 788 | // ok public meta |
|
| 789 | add_post_meta( $post_id, 'a_public_meta', 'foo5' ); |
|
| 790 | ||
| 791 | $this->sender->do_sync(); |
|
| 792 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, '_test_meta_key', true ) ); |
|
| 793 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, '_test_meta_array', true ) ); |
|
| 794 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, 'snapTW', true ) ); |
|
| 795 | $this->assertEquals( 'foo4', $this->server_replica_storage->get_metadata( 'post', $post_id, '_wp_attachment_metadata', true ) ); |
|
| 796 | $this->assertEquals( 'foo5', $this->server_replica_storage->get_metadata( 'post', $post_id, 'a_public_meta', true ) ); |
|
| 797 | // reset the storage, check value, and do full sync - storage should be set! |
|
| 798 | $this->server_replica_storage->reset(); |
|
| 799 | ||
| 800 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, '_test_meta_key', true ) ); |
|
| 801 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, '_test_meta_array', true ) ); |
|
| 802 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, 'snapTW', true ) ); |
|
| 803 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, '_wp_attachment_metadata', true ) ); |
|
| 804 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, 'a_public_meta', true ) ); |
|
| 805 | ||
| 806 | $this->full_sync->start(); |
|
| 807 | $this->sender->do_full_sync(); |
|
| 808 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, '_test_meta_key', true ) ); |
|
| 809 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, '_test_meta_array', true ) ); |
|
| 810 | $this->assertEquals( null, $this->server_replica_storage->get_metadata( 'post', $post_id, 'snapTW', true ) ); |
|
| 811 | $this->assertEquals( 'foo4', $this->server_replica_storage->get_metadata( 'post', $post_id, '_wp_attachment_metadata', true ) ); |
|
| 812 | $this->assertEquals( 'foo5', $this->server_replica_storage->get_metadata( 'post', $post_id, 'a_public_meta', true ) ); |
|
| 813 | } |
|
| 814 | ||
| 815 | function test_full_sync_sends_all_post_terms() { |
|
| 816 | $post_id = $this->factory->post->create(); |
|