| 1222 | |
| 1223 | /** |
| 1224 | * @ticket 20601 |
| 1225 | */ |
| 1226 | function test_user_member_of_blog() { |
| 1227 | global $wp_rewrite; |
| 1228 | |
| 1229 | $this->factory->blog->create(); |
| 1230 | $user_id = $this->factory->user->create(); |
| 1231 | $this->factory->blog->create( array( 'user_id' => $user_id ) ); |
| 1232 | |
| 1233 | $blogs = get_blogs_of_user( $user_id ); |
| 1234 | $this->assertCount( 2, $blogs ); |
| 1235 | $first = reset( $blogs )->userblog_id; |
| 1236 | remove_user_from_blog( $user_id, $first ); |
| 1237 | |
| 1238 | $blogs = get_blogs_of_user( $user_id ); |
| 1239 | $second = reset( $blogs )->userblog_id; |
| 1240 | $this->assertCount( 1, $blogs ); |
| 1241 | |
| 1242 | switch_to_blog( $first ); |
| 1243 | $wp_rewrite->init(); |
| 1244 | |
| 1245 | $this->go_to( get_author_posts_url( $user_id ) ); |
| 1246 | $this->assertQueryTrue( 'is_404' ); |
| 1247 | |
| 1248 | switch_to_blog( $second ); |
| 1249 | $wp_rewrite->init(); |
| 1250 | |
| 1251 | $this->go_to( get_author_posts_url( $user_id ) ); |
| 1252 | $this->assertQueryTrue( 'is_author', 'is_archive' ); |
| 1253 | |
| 1254 | add_user_to_blog( $first, $user_id, 'administrator' ); |
| 1255 | $blogs = get_blogs_of_user( $user_id ); |
| 1256 | $this->assertCount( 2, $blogs ); |
| 1257 | |
| 1258 | switch_to_blog( $first ); |
| 1259 | $wp_rewrite->init(); |
| 1260 | |
| 1261 | $this->go_to( get_author_posts_url( $user_id ) ); |
| 1262 | $this->assertQueryTrue( 'is_author', 'is_archive' ); |
| 1263 | } |