Completed
Push — try/refactor-secrets-and-token... ( 1bc8a1...a17499 )
by
unknown
33:04 queued 24:10
created

SecretsTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A set_up() 9 9 1
A tear_down() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php // phpcs:ignore WordPress.Files.FileName.NotHyphenatedLowercase
2
/**
3
 * Connection Manager functionality testing.
4
 *
5
 * @package automattic/jetpack-connection
6
 */
7
8
namespace Automattic\Jetpack\Connection;
9
10
use Automattic\Jetpack\Constants;
11
use PHPUnit\Framework\TestCase;
12
13
/**
14
 * Connection Manager functionality testing.
15
 */
16 View Code Duplication
class SecretsTest extends TestCase {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
18
	/**
19
	 * Temporary stack for `wp_redirect`.
20
	 *
21
	 * @var array
22
	 */
23
	protected $arguments_stack = array();
24
25
	/**
26
	 * User ID added for the test.
27
	 *
28
	 * @var int
29
	 */
30
	protected $user_id;
31
32
	const DEFAULT_TEST_CAPS = array( 'default_test_caps' );
33
34
	/**
35
	 * Initialize the object before running the test method.
36
	 *
37
	 * @before
38
	 */
39
	public function set_up() {
40
		$this->user_id = wp_insert_user(
41
			array(
42
				'user_login' => 'test_is_user_connected_with_user_id_logged_in',
43
				'user_pass'  => '123',
44
			)
45
		);
46
		wp_set_current_user( 0 );
47
	}
48
49
	/**
50
	 * Clean up the testing environment.
51
	 *
52
	 * @after
53
	 */
54
	public function tear_down() {
55
		wp_set_current_user( 0 );
56
		Constants::clear_constants();
57
	}
58
}
59