Completed
Push — update/sync-package ( 660c46 )
by
unknown
08:05
created

packages/sync/tests/php/test_Sync.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
use Automattic\Jetpack\Sync;
3
use PHPUnit\Framework\TestCase;
4
5
class WP_Test_Actions extends TestCase {
6
	function test_get_sync_status() {
7
		$sync = new Sync();
8
		$no_checksum = $sync->get_sync_status();
9
		$this->assertArrayNotHasKey( 'posts_checksum', $no_checksum );
10
		$this->assertArrayNotHasKey( 'comments_checksum', $no_checksum );
11
		$this->assertArrayNotHasKey( 'post_meta_checksum', $no_checksum );
12
		$this->assertArrayNotHasKey( 'comment_meta_checksum', $no_checksum );
13
14
		$kitchen_sink_checksum = Jetpack_Sync_Actions::get_sync_status(
15
			'posts_checksum,comments_checksum,post_meta_checksum,comment_meta_checksum'
16
		);
17
		$this->assertArrayHasKey( 'posts_checksum', $kitchen_sink_checksum );
18
		$this->assertArrayHasKey( 'comments_checksum', $kitchen_sink_checksum );
19
		$this->assertArrayHasKey( 'post_meta_checksum', $kitchen_sink_checksum );
20
		$this->assertArrayHasKey( 'comment_meta_checksum', $kitchen_sink_checksum );
21
22
		$posts = Jetpack_Sync_Actions::get_sync_status( 'posts_checksum' );
23
		$this->assertArrayHasKey( 'posts_checksum', $posts );
24
		$this->assertArrayNotHasKey( 'comments_checksum', $posts );
25
		$this->assertArrayNotHasKey( 'post_meta_checksum', $posts );
26
		$this->assertArrayNotHasKey( 'comment_meta_checksum', $posts );
27
28
		$comments = Jetpack_Sync_Actions::get_sync_status(
29
			'comments_checksum'
30
		);
31
		$this->assertArrayNotHasKey( 'posts_checksum', $comments );
32
		$this->assertArrayHasKey( 'comments_checksum', $comments );
33
		$this->assertArrayNotHasKey( 'post_meta_checksum', $comments );
34
		$this->assertArrayNotHasKey( 'comment_meta_checksum', $comments );
35
36
		$post_meta = Jetpack_Sync_Actions::get_sync_status(
37
			'post_meta_checksum'
38
		);
39
		$this->assertArrayNotHasKey( 'posts_checksum', $post_meta );
40
		$this->assertArrayNotHasKey( 'comments_checksum', $post_meta );
41
		$this->assertArrayHasKey( 'post_meta_checksum', $post_meta );
42
		$this->assertArrayNotHasKey( 'comment_meta_checksum', $post_meta );
43
44
		$comment_meta = Jetpack_Sync_Actions::get_sync_status(
45
			'comment_meta_checksum'
46
		);
47
		$this->assertArrayNotHasKey( 'posts_checksum', $comment_meta );
48
		$this->assertArrayNotHasKey( 'comments_checksum', $comment_meta );
49
		$this->assertArrayNotHasKey( 'post_meta_checksum', $comment_meta );
50
		$this->assertArrayHasKey( 'comment_meta_checksum', $comment_meta );
51
	}
52
53
	/**
54
	 * Mock a set of filters.
55
	 *
56
	 * @param array $args Array of filters with their arguments.
0 ignored issues
show
There is no parameter named $args. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
57
	 * @return phpmock\Mock The mock object.
58
	 */
59
	protected function mock_filters( $filters = array() ) {
60
		return $this->mock_function_with_args( 'apply_filters', $filters );
61
	}
62
}
63