Changeset 28541 for trunk/tests/phpunit/tests/post/revisions.php
- Timestamp:
- 05/22/2014 06:18:11 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post/revisions.php
r25002 r28541 339 339 } 340 340 } 341 342 /** 343 * @ticket 26042 344 */ 345 function test_wp_get_posts_revisions_sql() { 346 $post = get_default_post_to_edit( 'post', true ); 347 348 add_filter( 'query', array( $this, '_filter_query' ) ); 349 350 wp_get_post_revisions( $post->ID ); 351 } 352 353 function _filter_query( $sql ) { 354 remove_filter( 'query', array( $this, '_filter_query' ) ); 355 global $wpdb; 356 $this->assertContains( "ORDER BY $wpdb->posts.post_date ASC, $wpdb->posts.ID ASC", $sql ); 357 return $sql; 358 } 359 360 /** 361 * @ticket 26042 362 */ 363 function test_revision_order() { 364 $ok = 0; 365 $reversed = 0; 366 367 for ( $i = 0; $i < 100; $i++ ) { 368 $post_id = $this->factory->post->create( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) ); 369 370 for ( $j = 1; $j < 3; $j++ ) { 371 wp_update_post( array( 'post_content' => 'updated post' . $j , 'ID' => $post_id ) ); 372 } 373 374 $revisions = wp_get_post_revisions( $post_id ); 375 $first = array_shift( $revisions ); 376 $last = array_pop( $revisions ); 377 378 if ( $first->ID < $last->ID ) { 379 $reversed++; 380 } else { 381 $ok++; 382 } 383 } 384 385 $this->assertEquals( 100, $ok ); 386 $this->assertEquals( 0, $reversed ); 387 } 341 388 }
Note: See TracChangeset
for help on using the changeset viewer.