Changeset 42343 for trunk/tests/phpunit/tests/xmlrpc/wp/getTerms.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/xmlrpc/wp/getTerms.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/xmlrpc/wp/getTerms.php
r40916 r42343 43 43 44 44 // make sure there's at least one category 45 $cat = wp_insert_term( 'term_' . __FUNCTION__ , 'category' );45 $cat = wp_insert_term( 'term_' . __FUNCTION__, 'category' ); 46 46 47 47 $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category' ) ); 48 48 $this->assertNotIXRError( $results ); 49 49 50 foreach ( $results as $term ) {50 foreach ( $results as $term ) { 51 51 $this->assertInternalType( 'int', $term['count'] ); 52 52 … … 66 66 67 67 // create a taxonomy and some terms for it 68 $tax_name = 'wp_getTerms_custom_taxonomy';68 $tax_name = 'wp_getTerms_custom_taxonomy'; 69 69 $num_terms = 12; 70 70 register_taxonomy( $tax_name, 'post' ); 71 for ( $i = 0; $i < $num_terms; $i++ )71 for ( $i = 0; $i < $num_terms; $i++ ) { 72 72 wp_insert_term( "term_{$i}", $tax_name ); 73 73 } 74 74 75 75 // test fetching all terms … … 83 83 84 84 // test paged results 85 $filter = array( 'number' => 5 );85 $filter = array( 'number' => 5 ); 86 86 $results2 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) ); 87 87 $this->assertNotIXRError( $results ); … … 90 90 91 91 $filter['offset'] = 10; 92 $results3 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) );92 $results3 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) ); 93 93 $this->assertNotIXRError( $results3 ); 94 94 $this->assertEquals( $num_terms - 10, count( $results3 ) ); … … 96 96 97 97 // test hide_empty (since none have been attached to posts yet, all should be hidden 98 $filter = array( 'hide_empty' => true );98 $filter = array( 'hide_empty' => true ); 99 99 $results4 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) ); 100 100 $this->assertNotIXRError( $results4 ); 101 101 $this->assertEquals( 0, count( $results4 ) ); 102 102 103 unset( $GLOBALS['wp_taxonomies'][$tax_name]);103 unset( $GLOBALS['wp_taxonomies'][ $tax_name ] ); 104 104 } 105 105 … … 113 113 self::factory()->post->create_many( 3, array( 'post_category' => array( $cat2 ) ) ); 114 114 115 $filter = array( 'orderby' => 'count', 'order' => 'DESC' ); 115 $filter = array( 116 'orderby' => 'count', 117 'order' => 'DESC', 118 ); 116 119 $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) ); 117 120 $this->assertNotIXRError( $results ); 118 121 $this->assertNotEquals( 0, count( $results ) ); 119 122 120 foreach ( $results as $term ) {123 foreach ( $results as $term ) { 121 124 if ( $term['term_id'] == $cat1 ) { 122 125 break; // found cat1 first as expected 123 } 124 else if ( $term['term_id'] == $cat2 ) { 126 } elseif ( $term['term_id'] == $cat2 ) { 125 127 $this->assertFalse( false, 'Incorrect category ordering.' ); 126 128 } … … 131 133 $this->make_user_by_role( 'editor' ); 132 134 133 $name = __FUNCTION__;135 $name = __FUNCTION__; 134 136 $name_id = wp_create_category( $name ); 135 137 136 138 // search by full name 137 $filter = array( 'search' => $name );139 $filter = array( 'search' => $name ); 138 140 $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) ); 139 141 $this->assertNotIXRError( $results ); … … 143 145 144 146 // search by partial name 145 $filter = array( 'search' => substr( $name, 0, 10 ) );147 $filter = array( 'search' => substr( $name, 0, 10 ) ); 146 148 $results2 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) ); 147 149 $this->assertNotIXRError( $results2 );
Note: See TracChangeset
for help on using the changeset viewer.