| 2351 | |
| 2352 | /** |
| 2353 | * @ticket 46351 |
| 2354 | */ |
| 2355 | public function test_wpmu_new_blog_action_backward_compatible() { |
| 2356 | // We are testing deprecated hook. Register it to expected deprecated notices. |
| 2357 | $this->setExpectedDeprecated( 'wpmu_new_blog' ); |
| 2358 | add_action( 'wpmu_new_blog', array( $this, 'wpmu_new_blog_callback' ), 10, 6 ); |
| 2359 | |
| 2360 | $meta = array( |
| 2361 | 'public' => -1, // `public` is one of the defaults metas in `wpmu_create_blog' function prior WordPress 5.1.0. |
| 2362 | 'lang_id' => 11, |
| 2363 | 'mature' => 0, |
| 2364 | ); |
| 2365 | $blog_id = wpmu_create_blog( 'testsite1.example.org', '/new-blog/', 'New Blog', get_current_user_id(), $meta, 1 ); |
| 2366 | |
| 2367 | remove_action( 'populate_options', array( $this, 'wpmu_new_blog_callback' ), 10 ); |
| 2368 | } |
| 2369 | |
| 2370 | /** |
| 2371 | * Capture the $meta value passed to the wpmu_new_blog action and compare it. |
| 2372 | */ |
| 2373 | public function wpmu_new_blog_callback( $blog_id, $user_id, $domain, $path, $network_id, $meta ) { |
| 2374 | $expected_meta = array( |
| 2375 | 'public' => -1, |
| 2376 | 'WPLANG' => 'en_US', // WPLANG is another default meta in `wpmu_create_blog` function prior WordPress 5.1.0. |
| 2377 | 'lang_id' => 11, |
| 2378 | 'mature' => 0, |
| 2379 | ); |
| 2380 | $this->assertArraySubset( $expected_meta, $meta ); |
| 2381 | } |