Changeset 30175
- Timestamp:
- 11/02/2014 01:04:47 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/multisite/site.php
r30174 r30175 445 445 446 446 /** 447 * Test fetching a blog that doesn't exist andagain after it exists.447 * Test cached data for a site that does not exist and then again after it exists. 448 448 * 449 449 * @ticket 23405 450 450 */ 451 function test_get_blog_details_blog_does_not_exist() { 452 global $wpdb; 453 454 $blog_id = $wpdb->get_var( "SELECT MAX(blog_id) FROM $wpdb->blogs" ); 455 456 // An idosyncrancy of the unit tests is that the max blog_id gets reset 457 // to 1 in between test cases but picks up where it previously left off 458 // on the next insert. If 1 is reported, burn a blog create to get 459 // the max counter back in sync. 460 if ( 1 == $blog_id ) { 461 $blog_id = $this->factory->blog->create(); 462 } 451 function test_get_blog_details_when_site_does_not_exist() { 452 // Create an unused site so that we can then assume an invalid site ID. 453 $blog_id = $this->factory->blog->create(); 463 454 $blog_id++; 464 455 465 $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) ); 466 $this->assertFalse( get_blog_details( $blog_id ) ); 456 // Prime the cache for an invalid site. 457 get_blog_details( $blog_id ); 458 459 // When the cache is primed with an invalid site, the value is set to -1. 467 460 $this->assertEquals( -1, wp_cache_get( $blog_id, 'blog-details' ) ); 468 $this->assertFalse( get_blog_details( $blog_id ) ); 469 $this->assertEquals( -1, wp_cache_get( $blog_id, 'blog-details' ) ); 470 471 $this->assertEquals( $blog_id, $this->factory->blog->create() ); 461 462 // Create a site in the invalid site's place. 463 $this->factory->blog->create(); 464 465 // When a new site is created, its cache is cleared through refresh_blog_details. 472 466 $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) ); 473 467 474 468 $blog = get_blog_details( $blog_id ); 475 $this->assertEquals( $blog_id, $blog->blog_id ); 469 470 // When the cache is refreshed, it should now equal the site data. 476 471 $this->assertEquals( $blog, wp_cache_get( $blog_id, 'blog-details' ) ); 477 478 wpmu_delete_blog( $blog_id );479 $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) );480 $blog->deleted = '1';481 $this->assertEQuals( $blog, get_blog_details( $blog_id ) );482 $this->assertEquals( $blog, wp_cache_get( $blog_id, 'blog-details' ) );483 484 wpmu_delete_blog( $blog_id, true );485 $this->assertFalse( get_blog_details( $blog_id ) );486 $this->assertEquals( -1, wp_cache_get( $blog_id, 'blog-details' ) );487 472 } 488 473
Note: See TracChangeset
for help on using the changeset viewer.