@@ 695-704 (lines=10) @@ | ||
692 | $this->assertErrorResponse( 'rest_term_invalid', $response, 400 ); |
|
693 | } |
|
694 | ||
695 | public function test_delete_item() { |
|
696 | wp_set_current_user( $this->administrator ); |
|
697 | $term = get_term_by( 'id', $this->factory->category->create( array( 'name' => 'Deleted Category' ) ), 'category' ); |
|
698 | $request = new WP_REST_Request( 'DELETE', '/wp/v2/categories/' . $term->term_id ); |
|
699 | $request->set_param( 'force', true ); |
|
700 | $response = $this->server->dispatch( $request ); |
|
701 | $this->assertEquals( 200, $response->get_status() ); |
|
702 | $data = $response->get_data(); |
|
703 | $this->assertEquals( 'Deleted Category', $data['name'] ); |
|
704 | } |
|
705 | ||
706 | public function test_delete_item_force_false() { |
|
707 | wp_set_current_user( $this->administrator ); |
@@ 537-546 (lines=10) @@ | ||
534 | $this->assertErrorResponse( 'rest_taxonomy_not_hierarchical', $response, 400 ); |
|
535 | } |
|
536 | ||
537 | public function test_delete_item() { |
|
538 | wp_set_current_user( $this->administrator ); |
|
539 | $term = get_term_by( 'id', $this->factory->tag->create( array( 'name' => 'Deleted Tag' ) ), 'post_tag' ); |
|
540 | $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id ); |
|
541 | $request->set_param( 'force', true ); |
|
542 | $response = $this->server->dispatch( $request ); |
|
543 | $this->assertEquals( 200, $response->get_status() ); |
|
544 | $data = $response->get_data(); |
|
545 | $this->assertEquals( 'Deleted Tag', $data['name'] ); |
|
546 | } |
|
547 | ||
548 | public function test_delete_item_force_false() { |
|
549 | wp_set_current_user( $this->administrator ); |
@@ 1552-1563 (lines=12) @@ | ||
1549 | $this->assertEquals( array(), $new_data['categories'] ); |
|
1550 | } |
|
1551 | ||
1552 | public function test_delete_item() { |
|
1553 | $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) ); |
|
1554 | wp_set_current_user( $this->editor_id ); |
|
1555 | ||
1556 | $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d', $post_id ) ); |
|
1557 | $response = $this->server->dispatch( $request ); |
|
1558 | ||
1559 | $this->assertNotInstanceOf( 'WP_Error', $response ); |
|
1560 | $this->assertEquals( 200, $response->get_status() ); |
|
1561 | $data = $response->get_data(); |
|
1562 | $this->assertEquals( 'Deleted post', $data['title']['raw'] ); |
|
1563 | } |
|
1564 | ||
1565 | public function test_delete_item_skip_trash() { |
|
1566 | $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) ); |
|
@@ 1565-1577 (lines=13) @@ | ||
1562 | $this->assertEquals( 'Deleted post', $data['title']['raw'] ); |
|
1563 | } |
|
1564 | ||
1565 | public function test_delete_item_skip_trash() { |
|
1566 | $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) ); |
|
1567 | wp_set_current_user( $this->editor_id ); |
|
1568 | ||
1569 | $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d', $post_id ) ); |
|
1570 | $request['force'] = true; |
|
1571 | $response = $this->server->dispatch( $request ); |
|
1572 | ||
1573 | $this->assertNotInstanceOf( 'WP_Error', $response ); |
|
1574 | $this->assertEquals( 200, $response->get_status() ); |
|
1575 | $data = $response->get_data(); |
|
1576 | $this->assertEquals( 'Deleted post', $data['title']['raw'] ); |
|
1577 | } |
|
1578 | ||
1579 | public function test_delete_item_already_trashed() { |
|
1580 | $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) ); |