Code Duplication    Length = 16-16 lines in 2 locations

projects/packages/backup/tests/php/test-rest-controller.php 2 locations

@@ 75-90 (lines=16) @@
72
	/**
73
	 * Testing the `/jetpack/v4/backup-helper-script` endpoint with admin user.
74
	 */
75
	public function test_backup_helper_script_unauthorized() {
76
		$user = wp_get_current_user();
77
		$user->set_role( 'administrator' );
78
		$body    = array(
79
			'helper' => 'dummy',
80
		);
81
		$request = new WP_REST_Request( 'POST', '/jetpack/v4/backup-helper-script' );
82
		$request->set_header( 'content-type', 'application/json' );
83
		$request->set_body( wp_json_encode( $body ) );
84
		$response = $this->server->dispatch( $request );
85
		$this->assertEquals( 401, $response->get_status() );
86
		$this->assertEquals( 'You are not allowed to perform this action.', $response->get_data()['message'] );
87
88
		// Cleanup.
89
		$user->remove_role( 'administrator' );
90
	}
91
92
	/**
93
	 * Testing the `/jetpack/v4/backup-helper-script` endpoint on success.
@@ 130-145 (lines=16) @@
127
	/**
128
	 * Testing the `/jetpack/v4/delete-backup-helper-script` endpoint with admin user.
129
	 */
130
	public function test_delete_backup_helper_script_unauthorized() {
131
		$user = wp_get_current_user();
132
		$user->set_role( 'administrator' );
133
		$body    = array(
134
			'path' => 'dummy',
135
		);
136
		$request = new WP_REST_Request( 'POST', '/jetpack/v4/delete-backup-helper-script' );
137
		$request->set_header( 'content-type', 'application/json' );
138
		$request->set_body( wp_json_encode( $body ) );
139
		$response = $this->server->dispatch( $request );
140
		$this->assertEquals( 401, $response->get_status() );
141
		$this->assertEquals( 'You are not allowed to perform this action.', $response->get_data()['message'] );
142
143
		// Cleanup.
144
		$user->remove_role( 'administrator' );
145
	}
146
147
	/**
148
	 * Testing the `/jetpack/v4/delete-backup-helper-script` endpoint on success.