Changeset 35224 for trunk/tests/phpunit/tests/query/postStatus.php
- Timestamp:
- 10/16/2015 07:51:32 PM (10 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/query/postStatus.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/query/postStatus.php
r35186 r35224 5 5 */ 6 6 class Tests_Query_PostStatus extends WP_UnitTestCase { 7 public static $editor_user ;8 public static $author_user ;7 public static $editor_user_id; 8 public static $author_user_id; 9 9 public static $editor_private_post; 10 10 public static $author_private_post; … … 13 13 14 14 public static function wpSetUpBeforeClass( $factory ) { 15 self::$editor_user = $factory->user->create( array( 'role' => 'editor' ) );16 self::$author_user = $factory->user->create( array( 'role' => 'author' ) );17 18 self::$editor_private_post = $factory->post->create( array( 'post_author' => self::$editor_user , 'post_status' => 'private' ) );19 self::$author_private_post = $factory->post->create( array( 'post_author' => self::$author_user , 'post_status' => 'private' ) );15 self::$editor_user_id = $factory->user->create( array( 'role' => 'editor' ) ); 16 self::$author_user_id = $factory->user->create( array( 'role' => 'author' ) ); 17 18 self::$editor_private_post = $factory->post->create( array( 'post_author' => self::$editor_user_id, 'post_status' => 'private' ) ); 19 self::$author_private_post = $factory->post->create( array( 'post_author' => self::$author_user_id, 'post_status' => 'private' ) ); 20 20 21 21 // Custom status with private=true. 22 22 register_post_status( 'privatefoo', array( 'private' => true ) ); 23 self::$editor_privatefoo_post = $factory->post->create( array( 'post_author' => self::$editor_user , 'post_status' => 'privatefoo' ) );24 self::$author_privatefoo_post = $factory->post->create( array( 'post_author' => self::$author_user , 'post_status' => 'privatefoo' ) );23 self::$editor_privatefoo_post = $factory->post->create( array( 'post_author' => self::$editor_user_id, 'post_status' => 'privatefoo' ) ); 24 self::$author_privatefoo_post = $factory->post->create( array( 'post_author' => self::$author_user_id, 'post_status' => 'privatefoo' ) ); 25 25 _unregister_post_status( 'privatefoo' ); 26 26 } 27 27 28 28 public static function wpTearDownAfterClass() { 29 if ( is_multisite() ) { 30 wpmu_delete_user( self::$editor_user ); 31 wpmu_delete_user( self::$author_user ); 32 } else { 33 wp_delete_user( self::$editor_user ); 34 wp_delete_user( self::$author_user ); 29 $ids = array( self::$editor_user_id, self::$author_user_id ); 30 foreach ( $ids as $id ) { 31 self::delete_user( $id ); 35 32 } 36 33 … … 87 84 88 85 public function test_private_should_be_included_only_for_current_user_if_perm_is_readable_and_user_cannot_read_others_posts() { 89 wp_set_current_user( self::$author_user );86 wp_set_current_user( self::$author_user_id ); 90 87 91 88 $q = new WP_Query( array( … … 102 99 103 100 public function test_private_should_be_included_for_all_users_if_perm_is_readable_and_user_can_read_others_posts() { 104 wp_set_current_user( self::$editor_user );101 wp_set_current_user( self::$editor_user_id ); 105 102 106 103 $q = new WP_Query( array( … … 118 115 119 116 public function test_private_should_be_included_only_for_current_user_if_perm_is_editable_and_user_cannot_read_others_posts() { 120 wp_set_current_user( self::$author_user );117 wp_set_current_user( self::$author_user_id ); 121 118 122 119 $q = new WP_Query( array( … … 133 130 134 131 public function test_private_should_be_included_for_all_users_if_perm_is_editable_and_user_can_read_others_posts() { 135 wp_set_current_user( self::$editor_user );132 wp_set_current_user( self::$editor_user_id ); 136 133 137 134 $q = new WP_Query( array( … … 183 180 184 181 public function test_private_statuses_should_be_included_when_current_user_can_read_private_posts() { 185 wp_set_current_user( self::$editor_user );182 wp_set_current_user( self::$editor_user_id ); 186 183 187 184 register_post_status( 'privatefoo', array( 'private' => true ) ); … … 196 193 197 194 public function test_private_statuses_should_not_be_included_when_current_user_cannot_read_private_posts() { 198 wp_set_current_user( self::$author_user );195 wp_set_current_user( self::$author_user_id ); 199 196 200 197 register_post_status( 'privatefoo', array( 'private' => true ) ); … … 227 224 register_post_type( 'foo_pt' ); 228 225 register_post_status( 'foo_ps', array( 'public' => false, 'protected' => true ) ); 229 $p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user ) );230 231 wp_set_current_user( self::$author_user );226 $p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user_id ) ); 227 228 wp_set_current_user( self::$author_user_id ); 232 229 233 230 $q = new WP_Query( array( … … 241 238 register_post_type( 'foo_pt' ); 242 239 register_post_status( 'foo_ps', array( 'public' => false, 'protected' => true ) ); 243 $p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user ) );244 245 wp_set_current_user( self::$editor_user );240 $p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) ); 241 242 wp_set_current_user( self::$editor_user_id ); 246 243 247 244 $q = new WP_Query( array( … … 255 252 register_post_type( 'foo_pt' ); 256 253 register_post_status( 'foo_ps', array( 'public' => false, 'private' => true ) ); 257 $p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user ) );258 259 wp_set_current_user( self::$author_user );254 $p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user_id ) ); 255 256 wp_set_current_user( self::$author_user_id ); 260 257 261 258 $q = new WP_Query( array( … … 269 266 register_post_type( 'foo_pt' ); 270 267 register_post_status( 'foo_ps', array( 'public' => false, 'private' => true ) ); 271 $p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user ) );272 273 wp_set_current_user( self::$editor_user );268 $p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) ); 269 270 wp_set_current_user( self::$editor_user_id ); 274 271 275 272 $q = new WP_Query( array( … … 283 280 register_post_type( 'foo_pt' ); 284 281 register_post_status( 'foo_ps', array( 'public' => false ) ); 285 $p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user ) );286 287 wp_set_current_user( self::$editor_user );282 $p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) ); 283 284 wp_set_current_user( self::$editor_user_id ); 288 285 289 286 $q = new WP_Query( array(
Note: See TracChangeset
for help on using the changeset viewer.