Code Duplication    Length = 23-25 lines in 2 locations

packages/licensing/tests/php/class-test-licensing.php 2 locations

@@ 247-269 (lines=23) @@
244
	/**
245
	 * Test attach_stored_licenses() logs request failure.
246
	 */
247
	public function test_attach_stored_licenses__returns_error() {
248
		$licenses = array( 'foo', 'bar' );
249
250
		$error = new WP_Error( 'foo' );
251
252
		$licensing = $this->createPartialMock(
253
			Licensing::class,
254
			array( 'stored_licenses', 'attach_licenses', 'log_error' )
255
		);
256
257
		$licensing->method( 'stored_licenses' )
258
			->willReturn( $licenses );
259
260
		$licensing->method( 'attach_licenses' )
261
			->with( $licenses )
262
			->willReturn( $error );
263
264
		$licensing->expects( $this->never() )->method( 'log_error' );
265
266
		$result = $licensing->attach_stored_licenses();
267
268
		$this->assertSame( $error, $result );
269
	}
270
271
	/**
272
	 * Test attach_stored_licenses() logs request failure.
@@ 274-298 (lines=25) @@
271
	/**
272
	 * Test attach_stored_licenses() logs request failure.
273
	 */
274
	public function test_attach_stored_licenses__logs_request_failure() {
275
		$licenses = array( 'foo', 'bar' );
276
277
		$error = new WP_Error( 'request_failed' );
278
279
		$licensing = $this->createPartialMock(
280
			Licensing::class,
281
			array( 'stored_licenses', 'attach_licenses', 'log_error' )
282
		);
283
284
		$licensing->method( 'stored_licenses' )
285
			->willReturn( $licenses );
286
287
		$licensing->method( 'attach_licenses' )
288
			->with( $licenses )
289
			->willReturn( $error );
290
291
		$licensing->expects( $this->once() )
292
			->method( 'log_error' )
293
			->with( 'Failed to attach your Jetpack license(s). Please try reconnecting Jetpack.' );
294
295
		$result = $licensing->attach_stored_licenses();
296
297
		$this->assertSame( $error, $result );
298
	}
299
300
	/**
301
	 * Test attach_stored_licenses() logs license attaching failures.