294 | | /** |
295 | | * @group activate |
296 | | */ |
297 | | public function test_activate_user_accounts_with_blogs() { |
298 | | global $wpdb, $current_site, $base; |
299 | | |
300 | | if ( ! is_multisite() ) { |
301 | | return; |
302 | | } |
303 | | |
304 | | $signups = array(); |
305 | | |
306 | | // Can't trust this first signup :( |
307 | | $signups['testpath1'] = self::factory()->signup->create( array( |
308 | | 'user_login' => 'testpath1', |
309 | | 'user_email' => 'blogone@example.com', |
310 | | 'domain' => '', |
311 | | 'path' => '', |
312 | | 'title' => '', |
313 | | 'activation_key' => 'activationkeyblogone', |
314 | | ) ); |
315 | | |
316 | | $signups['blogtwo'] = self::factory()->signup->create( array( |
317 | | 'user_login' => 'blogtwo', |
318 | | 'user_email' => 'blogtwo@example.com', |
319 | | 'domain' => $current_site->domain, |
320 | | 'path' => $base . 'blogtwo', |
321 | | 'title' => 'Blog Two', |
322 | | 'activation_key' => 'activationkeyblogtwo', |
323 | | ) ); |
324 | | |
325 | | $signups['blogthree'] = self::factory()->signup->create( array( |
326 | | 'user_login' => 'blogthree', |
327 | | 'user_email' => 'blogthree@example.com', |
328 | | 'domain' => '', |
329 | | 'path' => '', |
330 | | 'title' => '', |
331 | | 'activation_key' => 'activationkeyblogthree', |
332 | | ) ); |
333 | | |
334 | | $signups['blogfour'] = self::factory()->signup->create( array( |
335 | | 'user_login' => 'blogfour', |
336 | | 'user_email' => 'blogfour@example.com', |
337 | | 'domain' => $current_site->domain, |
338 | | 'path' => $base . 'blogfour', |
339 | | 'title' => 'Blog Four', |
340 | | 'activation_key' => 'activationkeyblogfour', |
341 | | ) ); |
342 | | |
343 | | // Neutralize db errors |
344 | | $suppress = $wpdb->suppress_errors(); |
345 | | |
346 | | $results = BP_Signup::activate( $signups ); |
347 | | |
348 | | $wpdb->suppress_errors( $suppress ); |
349 | | |
350 | | $this->assertNotEmpty( $results['activated'] ); |
351 | | |
352 | | $users = array(); |
353 | | |
354 | | foreach ( $signups as $login => $signup_id ) { |
355 | | $users[ $login ] = get_user_by( 'login', $login ); |
356 | | } |
357 | | |
358 | | $this->assertEqualSets( $results['activated'], wp_list_pluck( $users, 'ID' ) ); |
359 | | |
360 | | $blogs = array(); |
361 | | |
362 | | foreach ( $users as $path => $user ) { |
363 | | // Can't trust this first signup :( |
364 | | if ( 'testpath1' == $path ) { |
365 | | continue; |
366 | | } |
367 | | |
368 | | $blogs[ $path ] = get_active_blog_for_user( $user->ID ); |
369 | | } |
370 | | |
371 | | $blogs = array_filter( $blogs ); |
372 | | $blogs = array_map( 'basename', wp_list_pluck( $blogs, 'path' ) ); |
373 | | |
374 | | $this->assertEqualSets( $blogs, array_keys( $blogs ) ); |
375 | | } |
376 | | |