| @@ 492-554 (lines=63) @@ | ||
| 489 | * |
|
| 490 | * @covers ::add_users_menu |
|
| 491 | */ |
|
| 492 | public function test_add_users_menu() { |
|
| 493 | global $menu, $submenu; |
|
| 494 | ||
| 495 | // Current user can't list users. |
|
| 496 | wp_set_current_user( $this->factory->user->create( array( 'role' => 'editor' ) ) ); |
|
| 497 | $menu = array(); |
|
| 498 | ||
| 499 | static::$admin_menu->add_users_menu( true ); |
|
| 500 | ||
| 501 | $this->assertEmpty( $menu ); |
|
| 502 | ||
| 503 | // Reset. |
|
| 504 | wp_set_current_user( static::$user_id ); |
|
| 505 | $menu = static::$menu_data; |
|
| 506 | ||
| 507 | static::$admin_menu->add_users_menu( static::$domain ); |
|
| 508 | ||
| 509 | $slug = 'https://wordpress.com/people/team/' . static::$domain; |
|
| 510 | ||
| 511 | $users_menu_item = array( |
|
| 512 | 'Users', |
|
| 513 | 'list_users', |
|
| 514 | $slug, |
|
| 515 | 'Users', |
|
| 516 | 'menu-top toplevel_page_' . $slug, |
|
| 517 | 'toplevel_page_' . $slug, |
|
| 518 | 'dashicons-admin-users', |
|
| 519 | ); |
|
| 520 | $this->assertSame( $menu[70], $users_menu_item ); |
|
| 521 | $this->assertEmpty( $submenu['users.php'] ); |
|
| 522 | ||
| 523 | $all_people_submenu_item = array( |
|
| 524 | 'All People', |
|
| 525 | 'list_users', |
|
| 526 | $slug, |
|
| 527 | 'All People', |
|
| 528 | ); |
|
| 529 | $this->assertContains( $all_people_submenu_item, $submenu[ $slug ] ); |
|
| 530 | ||
| 531 | $add_new_submenu_item = array( |
|
| 532 | 'Add New', |
|
| 533 | 'promote_users', |
|
| 534 | 'https://wordpress.com/people/new/' . static::$domain, |
|
| 535 | 'Add New', |
|
| 536 | ); |
|
| 537 | $this->assertContains( $add_new_submenu_item, $submenu[ $slug ] ); |
|
| 538 | ||
| 539 | $profile_submenu_item = array( |
|
| 540 | 'My Profile', |
|
| 541 | 'read', |
|
| 542 | 'https://wordpress.com/me', |
|
| 543 | 'My Profile', |
|
| 544 | ); |
|
| 545 | $this->assertContains( $profile_submenu_item, $submenu[ $slug ] ); |
|
| 546 | ||
| 547 | $account_submenu_item = array( |
|
| 548 | 'Account Settings', |
|
| 549 | 'read', |
|
| 550 | 'https://wordpress.com/me/account', |
|
| 551 | 'Account Settings', |
|
| 552 | ); |
|
| 553 | $this->assertContains( $account_submenu_item, $submenu[ $slug ] ); |
|
| 554 | } |
|
| 555 | ||
| 556 | /** |
|
| 557 | * Tests add_tools_menu |
|
| @@ 335-397 (lines=63) @@ | ||
| 332 | * |
|
| 333 | * @covers ::add_users_menu |
|
| 334 | */ |
|
| 335 | public function test_add_users_menu() { |
|
| 336 | global $menu, $submenu; |
|
| 337 | ||
| 338 | // Current user can't list users. |
|
| 339 | wp_set_current_user( $this->factory->user->create( array( 'role' => 'editor' ) ) ); |
|
| 340 | $menu = array(); |
|
| 341 | ||
| 342 | static::$admin_menu->add_users_menu( true ); |
|
| 343 | ||
| 344 | $this->assertEmpty( $menu ); |
|
| 345 | ||
| 346 | // Reset. |
|
| 347 | wp_set_current_user( static::$user_id ); |
|
| 348 | $menu = static::$menu_data; |
|
| 349 | ||
| 350 | static::$admin_menu->add_users_menu( static::$domain ); |
|
| 351 | ||
| 352 | $slug = 'https://wordpress.com/people/team/' . static::$domain; |
|
| 353 | ||
| 354 | $users_menu_item = array( |
|
| 355 | 'Users', |
|
| 356 | 'list_users', |
|
| 357 | $slug, |
|
| 358 | 'Users', |
|
| 359 | 'menu-top toplevel_page_' . $slug, |
|
| 360 | 'toplevel_page_' . $slug, |
|
| 361 | 'dashicons-admin-users', |
|
| 362 | ); |
|
| 363 | $this->assertSame( $menu[70], $users_menu_item ); |
|
| 364 | $this->assertEmpty( $submenu['users.php'] ); |
|
| 365 | ||
| 366 | $all_people_submenu_item = array( |
|
| 367 | 'All People', |
|
| 368 | 'list_users', |
|
| 369 | $slug, |
|
| 370 | 'All People', |
|
| 371 | ); |
|
| 372 | $this->assertContains( $all_people_submenu_item, $submenu[ $slug ] ); |
|
| 373 | ||
| 374 | $add_new_submenu_item = array( |
|
| 375 | 'Add New', |
|
| 376 | 'promote_users', |
|
| 377 | 'https://wordpress.com/people/new/' . static::$domain, |
|
| 378 | 'Add New', |
|
| 379 | ); |
|
| 380 | $this->assertContains( $add_new_submenu_item, $submenu[ $slug ] ); |
|
| 381 | ||
| 382 | $profile_submenu_item = array( |
|
| 383 | 'My Profile', |
|
| 384 | 'read', |
|
| 385 | 'https://wordpress.com/me', |
|
| 386 | 'My Profile', |
|
| 387 | ); |
|
| 388 | $this->assertContains( $profile_submenu_item, $submenu[ $slug ] ); |
|
| 389 | ||
| 390 | $account_submenu_item = array( |
|
| 391 | 'Account Settings', |
|
| 392 | 'read', |
|
| 393 | 'https://wordpress.com/me/account', |
|
| 394 | 'Account Settings', |
|
| 395 | ); |
|
| 396 | $this->assertContains( $account_submenu_item, $submenu[ $slug ] ); |
|
| 397 | } |
|
| 398 | ||
| 399 | /** |
|
| 400 | * Tests add_tools_menu |
|