@@ 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 ); |
@@ 1568-1579 (lines=12) @@ | ||
1565 | $this->assertEquals( array(), $new_data['categories'] ); |
|
1566 | } |
|
1567 | ||
1568 | public function test_delete_item() { |
|
1569 | $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) ); |
|
1570 | wp_set_current_user( $this->editor_id ); |
|
1571 | ||
1572 | $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d', $post_id ) ); |
|
1573 | $response = $this->server->dispatch( $request ); |
|
1574 | ||
1575 | $this->assertNotInstanceOf( 'WP_Error', $response ); |
|
1576 | $this->assertEquals( 200, $response->get_status() ); |
|
1577 | $data = $response->get_data(); |
|
1578 | $this->assertEquals( 'Deleted post', $data['title']['raw'] ); |
|
1579 | } |
|
1580 | ||
1581 | public function test_delete_item_skip_trash() { |
|
1582 | $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) ); |
|
@@ 1581-1593 (lines=13) @@ | ||
1578 | $this->assertEquals( 'Deleted post', $data['title']['raw'] ); |
|
1579 | } |
|
1580 | ||
1581 | public function test_delete_item_skip_trash() { |
|
1582 | $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) ); |
|
1583 | wp_set_current_user( $this->editor_id ); |
|
1584 | ||
1585 | $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d', $post_id ) ); |
|
1586 | $request['force'] = true; |
|
1587 | $response = $this->server->dispatch( $request ); |
|
1588 | ||
1589 | $this->assertNotInstanceOf( 'WP_Error', $response ); |
|
1590 | $this->assertEquals( 200, $response->get_status() ); |
|
1591 | $data = $response->get_data(); |
|
1592 | $this->assertEquals( 'Deleted post', $data['title']['raw'] ); |
|
1593 | } |
|
1594 | ||
1595 | public function test_delete_item_already_trashed() { |
|
1596 | $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) ); |