| | 14 | /** |
| | 15 | * trac #22917 |
| | 16 | */ |
| | 17 | function test_enable_live_network_blog_counts_filter() { |
| | 18 | |
| | 19 | |
| | 20 | $blogcountstart = get_blog_count(); |
| | 21 | add_filter( 'enable_live_network_blog_counts', __return_false ); //false by default as of 3.6 |
| | 22 | $blog_ids = $this->factory->blog->create_many( 4 ); |
| | 23 | |
| | 24 | $this->assertEquals( $blogcountstart, (int) get_blog_count() ); //count only updated when cron runs, so likely unchanged |
| | 25 | |
| | 26 | add_filter( 'enable_live_network_blog_counts', __return_true ); //turns on live updating |
| | 27 | $blog_ids = $this->factory->blog->create_many( 4 ); |
| | 28 | |
| | 29 | $this->assertEquals( $blogcountstart+9, (int) get_blog_count() ); //count should be updated |
| | 30 | |
| | 31 | //clean up |
| | 32 | add_filter( 'enable_live_network_blog_counts', __return_false ); //turns on live updating |
| | 33 | foreach ( $blog_ids as $blog_id ) { |
| | 34 | wpmu_delete_blog( $blog_id, true ); |
| | 35 | } |
| | 36 | } |
| | 37 | /** |
| | 38 | * trac #22917 |
| | 39 | */ |
| | 40 | function test_enable_live_network_user_counts_filter() { |
| | 41 | |
| | 42 | add_filter( 'enable_live_network_user_counts', __return_false ); //false by default as of 3.6 |
| | 43 | // Refresh the cache |
| | 44 | wp_update_network_counts(); |
| | 45 | $start_count = get_user_count(); |
| | 46 | |
| | 47 | wpmu_create_user( 'user', 'pass', 'email'); |
| | 48 | |
| | 49 | $count = get_user_count(); // No change, cache not refreshed |
| | 50 | $this->assertEquals( $start_count, $count ); |
| | 51 | |
| | 52 | //start over with filter on |
| | 53 | wp_update_network_counts(); |
| | 54 | $start_count = get_user_count(); |
| | 55 | |
| | 56 | add_filter( 'enable_live_network_user_counts', __return_true ); //turns on live updating |
| | 57 | |
| | 58 | wpmu_create_user( 'user2', 'pass2', 'email2'); |
| | 59 | |
| | 60 | $count = get_user_count(); |
| | 61 | $this->assertEquals( $start_count + 1, $count ); |
| | 62 | |
| | 63 | //turn filter back off |
| | 64 | add_filter( 'enable_live_network_user_counts', __return_false ); //false by default as of 3.6 |
| | 65 | |
| | 66 | } |
| | 67 | |