Code Duplication    Length = 23-25 lines in 2 locations

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

@@ 264-286 (lines=23) @@
261
	/**
262
	 * Test attach_stored_licenses() logs request failure.
263
	 */
264
	public function test_attach_stored_licenses__returns_error() {
265
		$licenses = array( 'foo', 'bar' );
266
267
		$error = new WP_Error( 'foo' );
268
269
		$licensing = $this->createPartialMock(
270
			Licensing::class,
271
			array( 'stored_licenses', 'attach_licenses', 'log_error' )
272
		);
273
274
		$licensing->method( 'stored_licenses' )
275
			->willReturn( $licenses );
276
277
		$licensing->method( 'attach_licenses' )
278
			->with( $licenses )
279
			->willReturn( $error );
280
281
		$licensing->expects( $this->never() )->method( 'log_error' );
282
283
		$result = $licensing->attach_stored_licenses();
284
285
		$this->assertSame( $error, $result );
286
	}
287
288
	/**
289
	 * Test attach_stored_licenses() logs request failure.
@@ 291-315 (lines=25) @@
288
	/**
289
	 * Test attach_stored_licenses() logs request failure.
290
	 */
291
	public function test_attach_stored_licenses__logs_request_failure() {
292
		$licenses = array( 'foo', 'bar' );
293
294
		$error = new WP_Error( 'request_failed' );
295
296
		$licensing = $this->createPartialMock(
297
			Licensing::class,
298
			array( 'stored_licenses', 'attach_licenses', 'log_error' )
299
		);
300
301
		$licensing->method( 'stored_licenses' )
302
			->willReturn( $licenses );
303
304
		$licensing->method( 'attach_licenses' )
305
			->with( $licenses )
306
			->willReturn( $error );
307
308
		$licensing->expects( $this->once() )
309
			->method( 'log_error' )
310
			->with( 'Failed to attach your Jetpack license(s). Please try reconnecting Jetpack.' );
311
312
		$result = $licensing->attach_stored_licenses();
313
314
		$this->assertSame( $error, $result );
315
	}
316
317
	/**
318
	 * Test attach_stored_licenses() logs license attaching failures.