Skip to content

Commit

Permalink
Move tests to a new sync actions file
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla committed May 13, 2019
1 parent e61df46 commit 2df11c9
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 47 deletions.
50 changes: 50 additions & 0 deletions tests/php/sync/test_class.jetpack-sync-actions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

class WP_Test_Jetpack_Sync_Actions extends WP_UnitTestCase {
function test_get_sync_status() {
$no_checksum = Jetpack_Sync_Actions::get_sync_status();
$this->assertArrayNotHasKey( 'posts_checksum', $no_checksum );
$this->assertArrayNotHasKey( 'comments_checksum', $no_checksum );
$this->assertArrayNotHasKey( 'post_meta_checksum', $no_checksum );
$this->assertArrayNotHasKey( 'comment_meta_checksum', $no_checksum );

$kitchen_sink_checksum = Jetpack_Sync_Actions::get_sync_status(
'posts_checksum,comments_checksum,post_meta_checksum,comment_meta_checksum'
);
$this->assertArrayHasKey( 'posts_checksum', $kitchen_sink_checksum );
$this->assertArrayHasKey( 'comments_checksum', $kitchen_sink_checksum );
$this->assertArrayHasKey( 'post_meta_checksum', $kitchen_sink_checksum );
$this->assertArrayHasKey( 'comment_meta_checksum', $kitchen_sink_checksum );

$posts = Jetpack_Sync_Actions::get_sync_status( 'posts_checksum' );
$this->assertArrayHasKey( 'posts_checksum', $posts );
$this->assertArrayNotHasKey( 'comments_checksum', $posts );
$this->assertArrayNotHasKey( 'post_meta_checksum', $posts );
$this->assertArrayNotHasKey( 'comment_meta_checksum', $posts );

$comments = Jetpack_Sync_Actions::get_sync_status(
'comments_checksum'
);
$this->assertArrayNotHasKey( 'posts_checksum', $comments );
$this->assertArrayHasKey( 'comments_checksum', $comments );
$this->assertArrayNotHasKey( 'post_meta_checksum', $comments );
$this->assertArrayNotHasKey( 'comment_meta_checksum', $comments );

$post_meta = Jetpack_Sync_Actions::get_sync_status(
'post_meta_checksum'
);
$this->assertArrayNotHasKey( 'posts_checksum', $post_meta );
$this->assertArrayNotHasKey( 'comments_checksum', $post_meta );
$this->assertArrayHasKey( 'post_meta_checksum', $post_meta );
$this->assertArrayNotHasKey( 'comment_meta_checksum', $post_meta );

$comment_meta = Jetpack_Sync_Actions::get_sync_status(
'comment_meta_checksum'
);
$this->assertArrayNotHasKey( 'posts_checksum', $comment_meta );
$this->assertArrayNotHasKey( 'comments_checksum', $comment_meta );
$this->assertArrayNotHasKey( 'post_meta_checksum', $comment_meta );
$this->assertArrayHasKey( 'comment_meta_checksum', $comment_meta );
}
}

47 changes: 0 additions & 47 deletions tests/php/sync/test_class.jetpack-sync-integration.php
Original file line number Diff line number Diff line change
@@ -1,53 +1,6 @@
<?php

class WP_Test_Jetpack_Sync_Integration extends WP_Test_Jetpack_Sync_Base {

function test_get_sync_status() {
$no_checksum = Jetpack_Sync_Actions::get_sync_status();
$this->assertArrayNotHasKey( 'posts_checksum', $no_checksum );
$this->assertArrayNotHasKey( 'comments_checksum', $no_checksum );
$this->assertArrayNotHasKey( 'post_meta_checksum', $no_checksum );
$this->assertArrayNotHasKey( 'comment_meta_checksum', $no_checksum );

$kitchen_sink_checksum = Jetpack_Sync_Actions::get_sync_status(
'posts_checksum,comments_checksum,post_meta_checksum,comment_meta_checksum'
);
$this->assertArrayHasKey( 'posts_checksum', $kitchen_sink_checksum );
$this->assertArrayHasKey( 'comments_checksum', $kitchen_sink_checksum );
$this->assertArrayHasKey( 'post_meta_checksum', $kitchen_sink_checksum );
$this->assertArrayHasKey( 'comment_meta_checksum', $kitchen_sink_checksum );

$posts = Jetpack_Sync_Actions::get_sync_status( 'posts_checksum' );
$this->assertArrayHasKey( 'posts_checksum', $posts );
$this->assertArrayNotHasKey( 'comments_checksum', $posts );
$this->assertArrayNotHasKey( 'post_meta_checksum', $posts );
$this->assertArrayNotHasKey( 'comment_meta_checksum', $posts );

$comments = Jetpack_Sync_Actions::get_sync_status(
'comments_checksum'
);
$this->assertArrayNotHasKey( 'posts_checksum', $comments );
$this->assertArrayHasKey( 'comments_checksum', $comments );
$this->assertArrayNotHasKey( 'post_meta_checksum', $comments );
$this->assertArrayNotHasKey( 'comment_meta_checksum', $comments );

$post_meta = Jetpack_Sync_Actions::get_sync_status(
'post_meta_checksum'
);
$this->assertArrayNotHasKey( 'posts_checksum', $post_meta );
$this->assertArrayNotHasKey( 'comments_checksum', $post_meta );
$this->assertArrayHasKey( 'post_meta_checksum', $post_meta );
$this->assertArrayNotHasKey( 'comment_meta_checksum', $post_meta );

$comment_meta = Jetpack_Sync_Actions::get_sync_status(
'comment_meta_checksum'
);
$this->assertArrayNotHasKey( 'posts_checksum', $comment_meta );
$this->assertArrayNotHasKey( 'comments_checksum', $comment_meta );
$this->assertArrayNotHasKey( 'post_meta_checksum', $comment_meta );
$this->assertArrayHasKey( 'comment_meta_checksum', $comment_meta );
}

function test_sending_empties_queue() {
$this->factory->post->create();
$this->assertNotEmpty( $this->sender->get_sync_queue()->get_all() );
Expand Down

0 comments on commit 2df11c9

Please sign in to comment.