Code Duplication    Length = 10-10 lines in 2 locations

packages/roles/tests/php/test-roles.php 2 locations

@@ 92-101 (lines=10) @@
89
	 *
90
	 * @covers Automattic\Jetpack\Roles::translate_user_to_role
91
	 */
92
	public function test_user_to_role_with_role() {
93
		$user_mock = $this->getMockBuilder( 'WP_User' )->getMock();
94
		Functions\when( 'user_can' )->alias(
95
			function ( $user, $cap ) use ( $user_mock ) {
96
				return $user_mock === $user && 'administrator' === $cap;
97
			}
98
		);
99
100
		$this->assertEquals( 'administrator', $this->roles->translate_user_to_role( $user_mock ) );
101
	}
102
103
	/**
104
	 * Test translating an user to a role by capablity.
@@ 108-117 (lines=10) @@
105
	 *
106
	 * @covers Automattic\Jetpack\Roles::translate_user_to_role
107
	 */
108
	public function test_user_to_role_with_capability() {
109
		$user_mock = $this->getMockBuilder( 'WP_User' )->getMock();
110
		Functions\when( 'user_can' )->alias(
111
			function ( $user, $cap ) use ( $user_mock ) {
112
				return $user_mock === $user && 'edit_others_posts' === $cap;
113
			}
114
		);
115
116
		$this->assertEquals( 'editor', $this->roles->translate_user_to_role( $user_mock ) );
117
	}
118
119
	/**
120
	 * Test translating an user to a role with no match.