1- use wp_api:: {
2- posts:: {
3- PostCreateParams , PostId , PostListParams , PostRetrieveParams , PostUpdateParams ,
4- WpApiParamPostsOrderBy ,
5- } ,
6- request:: endpoint:: posts_endpoint:: PostEndpointType ,
1+ use wp_api:: navigations:: {
2+ NavigationCreateParams , NavigationId , NavigationListParams , NavigationRetrieveParams ,
3+ NavigationUpdateParams , WpApiParamNavigationsOrderBy ,
74} ;
85use wp_api_integration_tests:: prelude:: * ;
96
107#[ tokio:: test]
118#[ parallel]
129async fn create_navigation_err_cannot_create ( ) {
1310 api_client_as_subscriber ( )
14- . posts ( )
15- . create (
16- & PostEndpointType :: Navigation ,
17- & PostCreateParams {
18- ..Default :: default ( )
19- } ,
20- )
11+ . navigations ( )
12+ . create ( & NavigationCreateParams {
13+ ..Default :: default ( )
14+ } )
2115 . await
2216 . assert_wp_error ( WpErrorCode :: CannotCreate ) ;
2317}
@@ -26,14 +20,11 @@ async fn create_navigation_err_cannot_create() {
2620#[ parallel]
2721async fn create_navigation_err_cannot_create2 ( ) {
2822 api_client_as_subscriber ( )
29- . posts ( )
30- . create (
31- & PostEndpointType :: Navigation ,
32- & PostCreateParams {
33- title : Some ( "foo" . to_string ( ) ) ,
34- ..Default :: default ( )
35- } ,
36- )
23+ . navigations ( )
24+ . create ( & NavigationCreateParams {
25+ title : Some ( "foo" . to_string ( ) ) ,
26+ ..Default :: default ( )
27+ } )
3728 . await
3829 . assert_wp_error ( WpErrorCode :: CannotCreate ) ;
3930}
@@ -42,11 +33,8 @@ async fn create_navigation_err_cannot_create2() {
4233#[ parallel]
4334async fn delete_navigation_err_cannot_delete ( ) {
4435 api_client_as_subscriber ( )
45- . posts ( )
46- . delete (
47- & PostEndpointType :: Navigation ,
48- & PostId ( TestCredentials :: instance ( ) . navigation_id ) ,
49- )
36+ . navigations ( )
37+ . delete ( & NavigationId ( TestCredentials :: instance ( ) . navigation_id ) )
5038 . await
5139 . assert_wp_error ( WpErrorCode :: CannotDelete ) ;
5240}
@@ -55,14 +43,11 @@ async fn delete_navigation_err_cannot_delete() {
5543#[ parallel]
5644async fn list_err_no_search_term_defined ( ) {
5745 api_client ( )
58- . posts ( )
59- . list_with_edit_context (
60- & PostEndpointType :: Navigation ,
61- & PostListParams {
62- orderby : Some ( WpApiParamPostsOrderBy :: Relevance ) ,
63- ..Default :: default ( )
64- } ,
65- )
46+ . navigations ( )
47+ . list_with_edit_context ( & NavigationListParams {
48+ order_by : Some ( WpApiParamNavigationsOrderBy :: Relevance ) ,
49+ ..Default :: default ( )
50+ } )
6651 . await
6752 . assert_wp_error ( WpErrorCode :: NoSearchTermDefined ) ;
6853}
@@ -71,14 +56,11 @@ async fn list_err_no_search_term_defined() {
7156#[ parallel]
7257async fn list_err_order_by_include_missing_include ( ) {
7358 api_client ( )
74- . posts ( )
75- . list_with_edit_context (
76- & PostEndpointType :: Navigation ,
77- & PostListParams {
78- orderby : Some ( WpApiParamPostsOrderBy :: Include ) ,
79- ..Default :: default ( )
80- } ,
81- )
59+ . navigations ( )
60+ . list_with_edit_context ( & NavigationListParams {
61+ order_by : Some ( WpApiParamNavigationsOrderBy :: Include ) ,
62+ ..Default :: default ( )
63+ } )
8264 . await
8365 . assert_wp_error ( WpErrorCode :: OrderbyIncludeMissingInclude ) ;
8466}
@@ -87,14 +69,11 @@ async fn list_err_order_by_include_missing_include() {
8769#[ parallel]
8870async fn list_err_post_invalid_page_number ( ) {
8971 api_client ( )
90- . posts ( )
91- . list_with_edit_context (
92- & PostEndpointType :: Navigation ,
93- & PostListParams {
94- page : Some ( 99999999 ) ,
95- ..Default :: default ( )
96- } ,
97- )
72+ . navigations ( )
73+ . list_with_edit_context ( & NavigationListParams {
74+ page : Some ( 99999999 ) ,
75+ ..Default :: default ( )
76+ } )
9877 . await
9978 . assert_wp_error ( WpErrorCode :: PostInvalidPageNumber ) ;
10079}
@@ -103,11 +82,10 @@ async fn list_err_post_invalid_page_number() {
10382#[ parallel]
10483async fn retrieve_navigation_err_forbidden_context ( ) {
10584 api_client_as_subscriber ( )
106- . posts ( )
85+ . navigations ( )
10786 . retrieve_with_edit_context (
108- & PostEndpointType :: Navigation ,
109- & PostId ( TestCredentials :: instance ( ) . navigation_id ) ,
110- & PostRetrieveParams :: default ( ) ,
87+ & NavigationId ( TestCredentials :: instance ( ) . navigation_id ) ,
88+ & NavigationRetrieveParams :: default ( ) ,
11189 )
11290 . await
11391 . assert_wp_error ( WpErrorCode :: ForbiddenContext ) ;
@@ -117,11 +95,10 @@ async fn retrieve_navigation_err_forbidden_context() {
11795#[ parallel]
11896async fn retrieve_navigation_err_post_invalid_id ( ) {
11997 api_client ( )
120- . posts ( )
98+ . navigations ( )
12199 . retrieve_with_edit_context (
122- & PostEndpointType :: Navigation ,
123- & PostId ( 99999999 ) ,
124- & PostRetrieveParams :: default ( ) ,
100+ & NavigationId ( 99999999 ) ,
101+ & NavigationRetrieveParams :: default ( ) ,
125102 )
126103 . await
127104 . assert_wp_error ( WpErrorCode :: PostInvalidId ) ;
@@ -131,11 +108,10 @@ async fn retrieve_navigation_err_post_invalid_id() {
131108#[ parallel]
132109async fn update_navigation_err_cannot_edit ( ) {
133110 api_client_as_author ( )
134- . posts ( )
111+ . navigations ( )
135112 . update (
136- & PostEndpointType :: Navigation ,
137- & PostId ( TestCredentials :: instance ( ) . navigation_id ) ,
138- & PostUpdateParams :: default ( ) ,
113+ & NavigationId ( TestCredentials :: instance ( ) . navigation_id ) ,
114+ & NavigationUpdateParams :: default ( ) ,
139115 )
140116 . await
141117 . assert_wp_error ( WpErrorCode :: CannotEdit ) ;
@@ -145,11 +121,10 @@ async fn update_navigation_err_cannot_edit() {
145121#[ parallel]
146122async fn update_navigation_err_invalid_template ( ) {
147123 api_client ( )
148- . posts ( )
124+ . navigations ( )
149125 . update (
150- & PostEndpointType :: Navigation ,
151- & PostId ( TestCredentials :: instance ( ) . navigation_id ) ,
152- & PostUpdateParams {
126+ & NavigationId ( TestCredentials :: instance ( ) . navigation_id ) ,
127+ & NavigationUpdateParams {
153128 template : Some ( "foo" . to_string ( ) ) ,
154129 ..Default :: default ( )
155130 } ,
0 commit comments