Code Duplication    Length = 7-11 lines in 4 locations

tests/test-rest-attachments-controller.php 1 location

@@ 630-640 (lines=11) @@
627
		$this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
628
	}
629
630
	public function test_delete_item() {
631
		wp_set_current_user( $this->editor_id );
632
		$attachment_id = $this->factory->attachment->create_object( $this->test_file, 0, array(
633
			'post_mime_type' => 'image/jpeg',
634
			'post_excerpt'   => 'A sample caption',
635
		) );
636
		$request = new WP_REST_Request( 'DELETE', '/wp/v2/media/' . $attachment_id );
637
		$request['force'] = true;
638
		$response = $this->server->dispatch( $request );
639
		$this->assertEquals( 200, $response->get_status() );
640
	}
641
642
	public function test_delete_item_no_trash() {
643
		wp_set_current_user( $this->editor_id );

tests/test-rest-categories-controller.php 2 locations

@@ 547-554 (lines=8) @@
544
		$this->assertErrorResponse( 'rest_forbidden_context', $response, 401 );
545
	}
546
547
	public function test_get_term_private_taxonomy() {
548
		register_taxonomy( 'robin', 'post', array( 'public' => false ) );
549
		$term1 = $this->factory->term->create( array( 'name' => 'Cape', 'taxonomy' => 'robin' ) );
550
551
		$request = new WP_REST_Request( 'GET', '/wp/v2/terms/robin/' . $term1 );
552
		$response = $this->server->dispatch( $request );
553
		$this->assertErrorResponse( 'rest_no_route', $response, 404 );
554
	}
555
556
	public function test_get_item_incorrect_taxonomy() {
557
		register_taxonomy( 'robin', 'post' );
@@ 556-562 (lines=7) @@
553
		$this->assertErrorResponse( 'rest_no_route', $response, 404 );
554
	}
555
556
	public function test_get_item_incorrect_taxonomy() {
557
		register_taxonomy( 'robin', 'post' );
558
		$term1 = $this->factory->term->create( array( 'name' => 'Cape', 'taxonomy' => 'robin' ) );
559
		$request = new WP_REST_Request( 'GET', '/wp/v2/categories/' . $term1 );
560
		$response = $this->server->dispatch( $request );
561
		$this->assertErrorResponse( 'rest_term_invalid', $response, 404 );
562
	}
563
564
	public function test_create_item() {
565
		wp_set_current_user( $this->administrator );

tests/test-rest-tags-controller.php 1 location

@@ 432-439 (lines=8) @@
429
		$this->assertErrorResponse( 'rest_forbidden_context', $response, 401 );
430
	}
431
432
	public function test_get_term_private_taxonomy() {
433
		register_taxonomy( 'robin', 'post', array( 'public' => false ) );
434
		$term1 = $this->factory->term->create( array( 'name' => 'Cape', 'taxonomy' => 'robin' ) );
435
436
		$request = new WP_REST_Request( 'GET', '/wp/v2/terms/robin/' . $term1 );
437
		$response = $this->server->dispatch( $request );
438
		$this->assertErrorResponse( 'rest_no_route', $response, 404 );
439
	}
440
441
	public function test_get_item_incorrect_taxonomy() {
442
		register_taxonomy( 'robin', 'post' );