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

WP_Test_Actions   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 58
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_get_sync_status() 0 46 1
A mock_filters() 0 3 1
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
Bug introduced by
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