Changeset 42343 for trunk/tests/phpunit/tests/admin/includesListTable.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/admin/includesListTable.php
r41929 r42343 5 5 */ 6 6 class Tests_Admin_includesListTable extends WP_UnitTestCase { 7 protected static $top = array();8 protected static $children = array();7 protected static $top = array(); 8 protected static $children = array(); 9 9 protected static $grandchildren = array(); 10 protected static $post_ids = array();10 protected static $post_ids = array(); 11 11 12 12 /** … … 26 26 $num_posts = 5; 27 27 foreach ( range( 1, $num_posts ) as $i ) { 28 $p = $factory->post->create_and_get( array( 29 'post_type' => 'page', 30 'post_title' => sprintf( 'Top Level Page %d', $i ), 31 ) ); 32 33 self::$top[ $i ] = $p; 28 $p = $factory->post->create_and_get( 29 array( 30 'post_type' => 'page', 31 'post_title' => sprintf( 'Top Level Page %d', $i ), 32 ) 33 ); 34 35 self::$top[ $i ] = $p; 34 36 self::$post_ids[] = $p->ID; 35 37 } … … 39 41 foreach ( self::$top as $top => $top_page ) { 40 42 foreach ( range( 1, $num_children ) as $i ) { 41 $p = $factory->post->create_and_get( array( 42 'post_type' => 'page', 43 'post_parent' => $top_page->ID, 44 'post_title' => sprintf( 'Child %d', $i ), 45 ) ); 43 $p = $factory->post->create_and_get( 44 array( 45 'post_type' => 'page', 46 'post_parent' => $top_page->ID, 47 'post_title' => sprintf( 'Child %d', $i ), 48 ) 49 ); 46 50 47 51 self::$children[ $top ][ $i ] = $p; 48 self::$post_ids[] = $p->ID;52 self::$post_ids[] = $p->ID; 49 53 } 50 54 } … … 55 59 foreach ( self::$children[ $top ] as $child => $child_page ) { 56 60 foreach ( range( 1, $num_grandchildren ) as $i ) { 57 $p = $factory->post->create_and_get( array( 58 'post_type' => 'page', 59 'post_parent' => $child_page->ID, 60 'post_title' => sprintf( 'Grandchild %d', $i ), 61 ) ); 61 $p = $factory->post->create_and_get( 62 array( 63 'post_type' => 'page', 64 'post_parent' => $child_page->ID, 65 'post_title' => sprintf( 'Grandchild %d', $i ), 66 ) 67 ); 62 68 63 69 self::$grandchildren[ $top ][ $child ][ $i ] = $p; 64 self::$post_ids[] = $p->ID;70 self::$post_ids[] = $p->ID; 65 71 } 66 72 } … … 72 78 */ 73 79 function test_list_hierarchical_pages_first_page() { 74 $this->_test_list_hierarchical_page( array( 75 'paged' => 1, 76 'posts_per_page' => 2, 77 ), array( 78 self::$top[1]->ID, 79 self::$children[1][1]->ID, 80 ) ); 80 $this->_test_list_hierarchical_page( 81 array( 82 'paged' => 1, 83 'posts_per_page' => 2, 84 ), array( 85 self::$top[1]->ID, 86 self::$children[1][1]->ID, 87 ) 88 ); 81 89 } 82 90 … … 85 93 */ 86 94 function test_list_hierarchical_pages_second_page() { 87 $this->_test_list_hierarchical_page( array( 88 'paged' => 2, 89 'posts_per_page' => 2, 90 ), array( 91 self::$top[1]->ID, 92 self::$children[1][2]->ID, 93 self::$children[1][3]->ID, 94 ) ); 95 $this->_test_list_hierarchical_page( 96 array( 97 'paged' => 2, 98 'posts_per_page' => 2, 99 ), array( 100 self::$top[1]->ID, 101 self::$children[1][2]->ID, 102 self::$children[1][3]->ID, 103 ) 104 ); 95 105 } 96 106 … … 99 109 */ 100 110 function test_search_hierarchical_pages_first_page() { 101 $this->_test_list_hierarchical_page( array( 102 'paged' => 1, 103 'posts_per_page' => 2, 104 's' => 'Child', 105 ), array( 106 self::$children[1][1]->ID, 107 self::$children[1][2]->ID, 108 ) ); 111 $this->_test_list_hierarchical_page( 112 array( 113 'paged' => 1, 114 'posts_per_page' => 2, 115 's' => 'Child', 116 ), array( 117 self::$children[1][1]->ID, 118 self::$children[1][2]->ID, 119 ) 120 ); 109 121 } 110 122 … … 113 125 */ 114 126 function test_search_hierarchical_pages_second_page() { 115 $this->_test_list_hierarchical_page( array( 116 'paged' => 2, 117 'posts_per_page' => 2, 118 's' => 'Top', 119 ), array( 120 self::$top[3]->ID, 121 self::$top[4]->ID, 122 ) ); 127 $this->_test_list_hierarchical_page( 128 array( 129 'paged' => 2, 130 'posts_per_page' => 2, 131 's' => 'Top', 132 ), array( 133 self::$top[3]->ID, 134 self::$top[4]->ID, 135 ) 136 ); 123 137 } 124 138 … … 128 142 function test_grandchildren_hierarchical_pages_first_page() { 129 143 // page 6 is the first page with grandchildren 130 $this->_test_list_hierarchical_page( array( 131 'paged' => 6, 132 'posts_per_page' => 2, 133 ), array( 134 self::$top[3]->ID, 135 self::$children[3][1]->ID, 136 self::$grandchildren[3][1][1]->ID, 137 self::$grandchildren[3][1][2]->ID, 138 ) ); 144 $this->_test_list_hierarchical_page( 145 array( 146 'paged' => 6, 147 'posts_per_page' => 2, 148 ), array( 149 self::$top[3]->ID, 150 self::$children[3][1]->ID, 151 self::$grandchildren[3][1][1]->ID, 152 self::$grandchildren[3][1][2]->ID, 153 ) 154 ); 139 155 } 140 156 … … 144 160 function test_grandchildren_hierarchical_pages_second_page() { 145 161 // page 7 is the second page with grandchildren 146 $this->_test_list_hierarchical_page( array( 147 'paged' => 7, 148 'posts_per_page' => 2, 149 ), array( 150 self::$top[3]->ID, 151 self::$children[3][1]->ID, 152 self::$grandchildren[3][1][3]->ID, 153 self::$children[3][2]->ID, 154 ) ); 162 $this->_test_list_hierarchical_page( 163 array( 164 'paged' => 7, 165 'posts_per_page' => 2, 166 ), array( 167 self::$top[3]->ID, 168 self::$children[3][1]->ID, 169 self::$grandchildren[3][1][3]->ID, 170 self::$children[3][2]->ID, 171 ) 172 ); 155 173 } 156 174 … … 167 185 $GLOBALS['per_page'] = $args['posts_per_page']; 168 186 169 $args = array_merge( array( 170 'post_type' => 'page', 171 ), $args ); 187 $args = array_merge( 188 array( 189 'post_type' => 'page', 190 ), $args 191 ); 172 192 173 193 // Mimic the behaviour of `wp_edit_posts_query()`:
Note: See TracChangeset
for help on using the changeset viewer.