| @@ 983-1001 (lines=19) @@ | ||
| 980 | $this->assertFalse( $this->server_event_storage->get_most_recent_event( 'jetpack_full_sync_users' ) ); |
|
| 981 | } |
|
| 982 | ||
| 983 | function test_full_sync_can_sync_individual_posts() { |
|
| 984 | $sync_post_id = $this->factory->post->create(); |
|
| 985 | $sync_post_id_2 = $this->factory->post->create(); |
|
| 986 | $no_sync_post_id = $this->factory->post->create(); |
|
| 987 | ||
| 988 | $this->full_sync->start( array( 'posts' => array( $sync_post_id, $sync_post_id_2 ) ) ); |
|
| 989 | $this->sender->do_full_sync(); |
|
| 990 | ||
| 991 | $synced_posts_event = $this->server_event_storage->get_most_recent_event( 'jetpack_full_sync_posts' ); |
|
| 992 | ||
| 993 | $posts = $synced_posts_event->args[0]; |
|
| 994 | ||
| 995 | $this->assertEquals( 2, count( $posts ) ); |
|
| 996 | $this->assertEquals( $sync_post_id_2, $posts[0]->ID ); |
|
| 997 | $this->assertEquals( $sync_post_id, $posts[1]->ID ); |
|
| 998 | ||
| 999 | $sync_status = $this->full_sync->get_status(); |
|
| 1000 | $this->assertEquals( array( $sync_post_id, $sync_post_id_2 ), $sync_status['config']['posts'] ); |
|
| 1001 | } |
|
| 1002 | ||
| 1003 | function test_full_sync_can_sync_individual_comments() { |
|
| 1004 | $post_id = $this->factory->post->create(); |
|
| @@ 1024-1043 (lines=20) @@ | ||
| 1021 | $this->assertEquals( array( $sync_comment_id, $sync_comment_id_2 ), $sync_status['config']['comments'] ); |
|
| 1022 | } |
|
| 1023 | ||
| 1024 | function test_full_sync_can_sync_individual_users() { |
|
| 1025 | $sync_user_id = $this->factory->user->create(); |
|
| 1026 | $sync_user_id_2 = $this->factory->user->create(); |
|
| 1027 | $no_sync_user_id = $this->factory->user->create(); |
|
| 1028 | ||
| 1029 | $this->full_sync->start( array( 'users' => array( $sync_user_id, $sync_user_id_2 ) ) ); |
|
| 1030 | $this->sender->do_full_sync(); |
|
| 1031 | ||
| 1032 | $synced_users_event = $this->server_event_storage->get_most_recent_event( 'jetpack_full_sync_users' ); |
|
| 1033 | ||
| 1034 | $users = $synced_users_event->args['users']; |
|
| 1035 | ||
| 1036 | $this->assertEquals( 2, count( $users ) ); |
|
| 1037 | // The users are ordered in reverse order now. |
|
| 1038 | $this->assertEquals( $sync_user_id_2, $users[0]->ID ); |
|
| 1039 | $this->assertEquals( $sync_user_id, $users[1]->ID ); |
|
| 1040 | ||
| 1041 | $sync_status = $this->full_sync->get_status(); |
|
| 1042 | $this->assertEquals( array( $sync_user_id, $sync_user_id_2 ), $sync_status['config']['users'] ); |
|
| 1043 | } |
|
| 1044 | ||
| 1045 | function test_full_sync_doesnt_send_deleted_posts() { |
|
| 1046 | // previously, the behavior was to send false or throw errors - we |
|
| @@ 1233-1251 (lines=19) @@ | ||
| 1230 | $this->assertFalse( $this->server_event_storage->get_most_recent_event( 'jetpack_full_sync_users' ) ); |
|
| 1231 | } |
|
| 1232 | ||
| 1233 | function test_full_sync_can_sync_individual_posts() { |
|
| 1234 | $sync_post_id = $this->factory->post->create(); |
|
| 1235 | $sync_post_id_2 = $this->factory->post->create(); |
|
| 1236 | $no_sync_post_id = $this->factory->post->create(); |
|
| 1237 | ||
| 1238 | $this->full_sync->start( array( 'posts' => array( $sync_post_id, $sync_post_id_2 ) ) ); |
|
| 1239 | $this->sender->do_full_sync(); |
|
| 1240 | ||
| 1241 | $synced_posts_event = $this->server_event_storage->get_most_recent_event( 'jetpack_full_sync_posts' ); |
|
| 1242 | ||
| 1243 | $posts = $synced_posts_event->args[0]; |
|
| 1244 | ||
| 1245 | $this->assertEquals( 2, count( $posts ) ); |
|
| 1246 | $this->assertEquals( $sync_post_id_2, $posts[0]->ID ); |
|
| 1247 | $this->assertEquals( $sync_post_id, $posts[1]->ID ); |
|
| 1248 | ||
| 1249 | $sync_status = $this->full_sync->get_status(); |
|
| 1250 | $this->assertEquals( array( $sync_post_id, $sync_post_id_2 ), $sync_status['config']['posts'] ); |
|
| 1251 | } |
|
| 1252 | ||
| 1253 | function test_full_sync_can_sync_individual_comments() { |
|
| 1254 | $post_id = $this->factory->post->create(); |
|
| @@ 1274-1293 (lines=20) @@ | ||
| 1271 | $this->assertEquals( array( $sync_comment_id, $sync_comment_id_2 ), $sync_status['config']['comments'] ); |
|
| 1272 | } |
|
| 1273 | ||
| 1274 | function test_full_sync_can_sync_individual_users() { |
|
| 1275 | $sync_user_id = $this->factory->user->create(); |
|
| 1276 | $sync_user_id_2 = $this->factory->user->create(); |
|
| 1277 | $no_sync_user_id = $this->factory->user->create(); |
|
| 1278 | ||
| 1279 | $this->full_sync->start( array( 'users' => array( $sync_user_id, $sync_user_id_2) ) ); |
|
| 1280 | $this->sender->do_full_sync(); |
|
| 1281 | ||
| 1282 | $synced_users_event = $this->server_event_storage->get_most_recent_event( 'jetpack_full_sync_users' ); |
|
| 1283 | ||
| 1284 | $users = $synced_users_event->args['users']; |
|
| 1285 | ||
| 1286 | $this->assertEquals( 2, count( $users ) ); |
|
| 1287 | // The users are ordered in reverse order now. |
|
| 1288 | $this->assertEquals( $sync_user_id_2, $users[0]->ID ); |
|
| 1289 | $this->assertEquals( $sync_user_id, $users[1]->ID ); |
|
| 1290 | ||
| 1291 | $sync_status = $this->full_sync->get_status(); |
|
| 1292 | $this->assertEquals( array( $sync_user_id, $sync_user_id_2 ), $sync_status['config']['users'] ); |
|
| 1293 | } |
|
| 1294 | ||
| 1295 | function test_full_sync_doesnt_send_deleted_posts() { |
|
| 1296 | ||