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