Code Duplication    Length = 15-15 lines in 2 locations

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

@@ 564-578 (lines=15) @@
561
		$this->assertErrorResponse( 'rest_term_invalid', $response, 404 );
562
	}
563
564
	public function test_create_item() {
565
		wp_set_current_user( $this->administrator );
566
		$request = new WP_REST_Request( 'POST', '/wp/v2/categories' );
567
		$request->set_param( 'name', 'My Awesome Term' );
568
		$request->set_param( 'description', 'This term is so awesome.' );
569
		$request->set_param( 'slug', 'so-awesome' );
570
		$response = $this->server->dispatch( $request );
571
		$this->assertEquals( 201, $response->get_status() );
572
		$headers = $response->get_headers();
573
		$data = $response->get_data();
574
		$this->assertContains( '/wp/v2/categories/' . $data['id'], $headers['Location'] );
575
		$this->assertEquals( 'My Awesome Term', $data['name'] );
576
		$this->assertEquals( 'This term is so awesome.', $data['description'] );
577
		$this->assertEquals( 'so-awesome', $data['slug'] );
578
	}
579
580
	public function test_create_item_invalid_taxonomy() {
581
		wp_set_current_user( $this->administrator );

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

@@ 449-463 (lines=15) @@
446
		$this->assertErrorResponse( 'rest_term_invalid', $response, 404 );
447
	}
448
449
	public function test_create_item() {
450
		wp_set_current_user( $this->administrator );
451
		$request = new WP_REST_Request( 'POST', '/wp/v2/tags' );
452
		$request->set_param( 'name', 'My Awesome Term' );
453
		$request->set_param( 'description', 'This term is so awesome.' );
454
		$request->set_param( 'slug', 'so-awesome' );
455
		$response = $this->server->dispatch( $request );
456
		$this->assertEquals( 201, $response->get_status() );
457
		$headers = $response->get_headers();
458
		$data = $response->get_data();
459
		$this->assertContains( '/wp/v2/tags/' . $data['id'], $headers['Location'] );
460
		$this->assertEquals( 'My Awesome Term', $data['name'] );
461
		$this->assertEquals( 'This term is so awesome.', $data['description'] );
462
		$this->assertEquals( 'so-awesome', $data['slug'] );
463
	}
464
465
	public function test_create_item_incorrect_permissions() {
466
		wp_set_current_user( $this->subscriber );