Code Duplication    Length = 11-14 lines in 5 locations

apps/encryption/tests/lib/KeyManagerTest.php 5 locations

@@ 108-118 (lines=11) @@
105
		);
106
	}
107
108
	public function testGetPrivateKey() {
109
		$this->keyStorageMock->expects($this->any())
110
			->method('getUserKey')
111
			->with($this->equalTo($this->userId), $this->equalTo('privateKey'))
112
			->willReturn('privateKey');
113
114
115
		$this->assertSame('privateKey',
116
			$this->instance->getPrivateKey($this->userId)
117
		);
118
	}
119
120
	public function testGetPublicKey() {
121
		$this->keyStorageMock->expects($this->any())
@@ 120-130 (lines=11) @@
117
		);
118
	}
119
120
	public function testGetPublicKey() {
121
		$this->keyStorageMock->expects($this->any())
122
			->method('getUserKey')
123
			->with($this->equalTo($this->userId), $this->equalTo('publicKey'))
124
			->willReturn('publicKey');
125
126
127
		$this->assertSame('publicKey',
128
			$this->instance->getPublicKey($this->userId)
129
		);
130
	}
131
132
	public function testRecoveryKeyExists() {
133
		$this->keyStorageMock->expects($this->any())
@@ 155-168 (lines=14) @@
152
		$this->assertTrue($this->instance->checkRecoveryPassword('pass'));
153
	}
154
155
	public function testSetPublicKey() {
156
		$this->keyStorageMock->expects($this->any())
157
			->method('setUserKey')
158
			->with(
159
				$this->equalTo($this->userId),
160
				$this->equalTo('publicKey'),
161
				$this->equalTo('key'))
162
			->willReturn(true);
163
164
165
		$this->assertTrue(
166
			$this->instance->setPublicKey($this->userId, 'key')
167
		);
168
	}
169
170
	public function testSetPrivateKey() {
171
		$this->keyStorageMock->expects($this->any())
@@ 170-183 (lines=14) @@
167
		);
168
	}
169
170
	public function testSetPrivateKey() {
171
		$this->keyStorageMock->expects($this->any())
172
			->method('setUserKey')
173
			->with(
174
				$this->equalTo($this->userId),
175
				$this->equalTo('privateKey'),
176
				$this->equalTo('key'))
177
			->willReturn(true);
178
179
180
		$this->assertTrue(
181
			$this->instance->setPrivateKey($this->userId, 'key')
182
		);
183
	}
184
185
	/**
186
	 * @dataProvider dataTestUserHasKeys
@@ 188-198 (lines=11) @@
185
	/**
186
	 * @dataProvider dataTestUserHasKeys
187
	 */
188
	public function testUserHasKeys($key, $expected) {
189
		$this->keyStorageMock->expects($this->exactly(2))
190
			->method('getUserKey')
191
			->with($this->equalTo($this->userId), $this->anything())
192
			->willReturn($key);
193
194
195
		$this->assertSame($expected,
196
			$this->instance->userHasKeys($this->userId)
197
		);
198
	}
199
200
	public function dataTestUserHasKeys() {
201
		return [