Changeset 35164
- Timestamp:
- 10/14/2015 09:40:44 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/admin/includesListTable.php
r31730 r35164 5 5 */ 6 6 class Tests_Admin_includesListTable extends WP_UnitTestCase { 7 protected static $top; 8 protected static $children; 9 protected static $grandchildren; 10 protected static $post_ids; 11 7 12 function setUp() { 13 parent::setUp(); 8 14 set_current_screen( 'edit-page' ); 9 15 $GLOBALS['hook_suffix'] = ''; 10 16 $this->table = _get_list_table( 'WP_Posts_List_Table' ); 11 12 parent::setUp(); 17 } 18 19 public static function setUpBeforeClass() { 20 $factory = new WP_UnitTest_Factory(); 13 21 14 22 // note that our top/children/grandchildren arrays are 1-indexed … … 17 25 $num_posts = 5; 18 26 foreach ( range( 1, $num_posts ) as $i ) { 19 $ this->top[$i] = $this->factory->post->create_and_get( array(27 $p = $factory->post->create_and_get( array( 20 28 'post_type' => 'page', 21 29 'post_title' => sprintf( 'Top Level Page %d', $i ), 22 30 ) ); 31 32 self::$top[ $i ] = $p; 33 self::$post_ids[] = $p; 23 34 } 24 35 25 36 // create child pages 26 37 $num_children = 3; 27 foreach ( $this->top as $top => $top_page ) {38 foreach ( self::$top as $top => $top_page ) { 28 39 foreach ( range( 1, $num_children ) as $i ) { 29 $ this->children[$top][$i] = $this->factory->post->create_and_get( array(40 $p = $factory->post->create_and_get( array( 30 41 'post_type' => 'page', 31 42 'post_parent' => $top_page->ID, 32 43 'post_title' => sprintf( 'Child %d', $i ), 33 44 ) ); 45 46 self::$children[ $top ][ $i ] = $p; 47 self::$post_ids[] = $p; 34 48 } 35 49 } … … 38 52 $num_grandchildren = 3; 39 53 foreach ( range( 3, 4 ) as $top ) { 40 foreach ( $this->children[$top] as $child => $child_page ) {54 foreach ( self::$children[ $top ] as $child => $child_page ) { 41 55 foreach ( range( 1, $num_grandchildren ) as $i ) { 42 $ this->grandchildren[$top][$child][$i] = $this->factory->post->create_and_get( array(56 $p = $factory->post->create_and_get( array( 43 57 'post_type' => 'page', 44 58 'post_parent' => $child_page->ID, 45 59 'post_title' => sprintf( 'Grandchild %d', $i ), 46 60 ) ); 61 62 self::$grandchildren[ $top ][ $child ][ $i ] = $p; 63 self::$post_ids = $p; 47 64 } 48 65 } 49 66 } 67 68 self::commit_transaction(); 69 } 70 71 public static function tearDownAfterClass() { 72 foreach ( self::$post_ids as $post_id ) { 73 wp_delete_post( $post_id, true ); 74 } 75 76 self::commit_transaction(); 50 77 } 51 78 … … 58 85 'posts_per_page' => 2, 59 86 ), array( 60 $this->top[1]->ID,61 $this->children[1][1]->ID,87 self::$top[1]->ID, 88 self::$children[1][1]->ID, 62 89 ) ); 63 90 } … … 71 98 'posts_per_page' => 2, 72 99 ), array( 73 $this->top[1]->ID,74 $this->children[1][2]->ID,75 $this->children[1][3]->ID,100 self::$top[1]->ID, 101 self::$children[1][2]->ID, 102 self::$children[1][3]->ID, 76 103 ) ); 77 104 } … … 86 113 's' => 'Child', 87 114 ), array( 88 $this->children[1][1]->ID,89 $this->children[1][2]->ID,115 self::$children[1][1]->ID, 116 self::$children[1][2]->ID, 90 117 ) ); 91 118 } … … 100 127 's' => 'Top', 101 128 ), array( 102 $this->top[3]->ID,103 $this->top[4]->ID,129 self::$top[3]->ID, 130 self::$top[4]->ID, 104 131 ) ); 105 132 } … … 114 141 'posts_per_page' => 2, 115 142 ), array( 116 $this->top[3]->ID,117 $this->children[3][1]->ID,118 $this->grandchildren[3][1][1]->ID,119 $this->grandchildren[3][1][2]->ID,143 self::$top[3]->ID, 144 self::$children[3][1]->ID, 145 self::$grandchildren[3][1][1]->ID, 146 self::$grandchildren[3][1][2]->ID, 120 147 ) ); 121 148 } … … 130 157 'posts_per_page' => 2, 131 158 ), array( 132 $this->top[3]->ID,133 $this->children[3][1]->ID,134 $this->grandchildren[3][1][3]->ID,135 $this->children[3][2]->ID,159 self::$top[3]->ID, 160 self::$children[3][1]->ID, 161 self::$grandchildren[3][1][3]->ID, 162 self::$children[3][2]->ID, 136 163 ) ); 137 164 }
Note: See TracChangeset
for help on using the changeset viewer.