|
@@ 1986-2009 (lines=24) @@
|
| 1983 |
|
$this->assertErrorResponse('rest_invalid_param', $response, 400); |
| 1984 |
|
} |
| 1985 |
|
|
| 1986 |
|
public function test_delete_user_reassign_passed_as_boolean_false_trashes_post() |
| 1987 |
|
{ |
| 1988 |
|
$user_id = $this->factory->user->create(); |
| 1989 |
|
|
| 1990 |
|
$this->allow_user_to_manage_multisite(); |
| 1991 |
|
wp_set_current_user(self::$user); |
| 1992 |
|
|
| 1993 |
|
$test_post = $this->factory->post->create( |
| 1994 |
|
array( |
| 1995 |
|
'post_author' => $user_id, |
| 1996 |
|
) |
| 1997 |
|
); |
| 1998 |
|
|
| 1999 |
|
$request = new WP_REST_Request('DELETE', sprintf('/wp/v2/users/%d', $user_id)); |
| 2000 |
|
$request['force'] = true; |
| 2001 |
|
$request->set_param('reassign', false); |
| 2002 |
|
$response = $this->server->dispatch($request); |
| 2003 |
|
|
| 2004 |
|
// Not implemented in multisite. |
| 2005 |
|
if (is_multisite() ) { |
| 2006 |
|
$this->assertErrorResponse('rest_cannot_delete', $response, 501); |
| 2007 |
|
return; |
| 2008 |
|
} |
| 2009 |
|
|
| 2010 |
|
$test_post = get_post($test_post); |
| 2011 |
|
$this->assertEquals('trash', $test_post->post_status); |
| 2012 |
|
} |
|
@@ 2014-2037 (lines=24) @@
|
| 2011 |
|
$this->assertEquals('trash', $test_post->post_status); |
| 2012 |
|
} |
| 2013 |
|
|
| 2014 |
|
public function test_delete_user_reassign_passed_as_string_false_trashes_post() |
| 2015 |
|
{ |
| 2016 |
|
$user_id = $this->factory->user->create(); |
| 2017 |
|
|
| 2018 |
|
$this->allow_user_to_manage_multisite(); |
| 2019 |
|
wp_set_current_user(self::$user); |
| 2020 |
|
|
| 2021 |
|
$test_post = $this->factory->post->create( |
| 2022 |
|
array( |
| 2023 |
|
'post_author' => $user_id, |
| 2024 |
|
) |
| 2025 |
|
); |
| 2026 |
|
|
| 2027 |
|
$request = new WP_REST_Request('DELETE', sprintf('/wp/v2/users/%d', $user_id)); |
| 2028 |
|
$request['force'] = true; |
| 2029 |
|
$request->set_param('reassign', 'false'); |
| 2030 |
|
$response = $this->server->dispatch($request); |
| 2031 |
|
|
| 2032 |
|
// Not implemented in multisite. |
| 2033 |
|
if (is_multisite() ) { |
| 2034 |
|
$this->assertErrorResponse('rest_cannot_delete', $response, 501); |
| 2035 |
|
return; |
| 2036 |
|
} |
| 2037 |
|
|
| 2038 |
|
$test_post = get_post($test_post); |
| 2039 |
|
$this->assertEquals('trash', $test_post->post_status); |
| 2040 |
|
} |
|
@@ 2042-2065 (lines=24) @@
|
| 2039 |
|
$this->assertEquals('trash', $test_post->post_status); |
| 2040 |
|
} |
| 2041 |
|
|
| 2042 |
|
public function test_delete_user_reassign_passed_as_empty_string_trashes_post() |
| 2043 |
|
{ |
| 2044 |
|
$user_id = $this->factory->user->create(); |
| 2045 |
|
|
| 2046 |
|
$this->allow_user_to_manage_multisite(); |
| 2047 |
|
wp_set_current_user(self::$user); |
| 2048 |
|
|
| 2049 |
|
$test_post = $this->factory->post->create( |
| 2050 |
|
array( |
| 2051 |
|
'post_author' => $user_id, |
| 2052 |
|
) |
| 2053 |
|
); |
| 2054 |
|
|
| 2055 |
|
$request = new WP_REST_Request('DELETE', sprintf('/wp/v2/users/%d', $user_id)); |
| 2056 |
|
$request['force'] = true; |
| 2057 |
|
$request->set_param('reassign', ''); |
| 2058 |
|
$response = $this->server->dispatch($request); |
| 2059 |
|
|
| 2060 |
|
// Not implemented in multisite. |
| 2061 |
|
if (is_multisite() ) { |
| 2062 |
|
$this->assertErrorResponse('rest_cannot_delete', $response, 501); |
| 2063 |
|
return; |
| 2064 |
|
} |
| 2065 |
|
|
| 2066 |
|
$test_post = get_post($test_post); |
| 2067 |
|
$this->assertEquals('trash', $test_post->post_status); |
| 2068 |
|
} |
|
@@ 2070-2093 (lines=24) @@
|
| 2067 |
|
$this->assertEquals('trash', $test_post->post_status); |
| 2068 |
|
} |
| 2069 |
|
|
| 2070 |
|
public function test_delete_user_reassign_passed_as_0_reassigns_author() |
| 2071 |
|
{ |
| 2072 |
|
$user_id = $this->factory->user->create(); |
| 2073 |
|
|
| 2074 |
|
$this->allow_user_to_manage_multisite(); |
| 2075 |
|
wp_set_current_user(self::$user); |
| 2076 |
|
|
| 2077 |
|
$test_post = $this->factory->post->create( |
| 2078 |
|
array( |
| 2079 |
|
'post_author' => $user_id, |
| 2080 |
|
) |
| 2081 |
|
); |
| 2082 |
|
|
| 2083 |
|
$request = new WP_REST_Request('DELETE', sprintf('/wp/v2/users/%d', $user_id)); |
| 2084 |
|
$request['force'] = true; |
| 2085 |
|
$request->set_param('reassign', 0); |
| 2086 |
|
$response = $this->server->dispatch($request); |
| 2087 |
|
|
| 2088 |
|
// Not implemented in multisite. |
| 2089 |
|
if (is_multisite() ) { |
| 2090 |
|
$this->assertErrorResponse('rest_cannot_delete', $response, 501); |
| 2091 |
|
return; |
| 2092 |
|
} |
| 2093 |
|
|
| 2094 |
|
$test_post = get_post($test_post); |
| 2095 |
|
$this->assertEquals(0, $test_post->post_author); |
| 2096 |
|
} |