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