1
0
Fork 0
mirror of https://github.com/buddypress/buddypress.git synced 2026-07-21 20:54:17 +08:00
buddypress/tests/phpunit/testcases/core/nav/bpGetNavMenuItems.php
Boone B Gorges 0ed016254c Use static factory method throughout PHPUnit tests.
See #7620.

git-svn-id: https://buddypress.svn.wordpress.org/trunk@11737 cdf35c40-ae34-48e0-9cc9-0c9da1808c22
2017-11-03 19:44:10 +00:00

55 lines
1.3 KiB
PHP

<?php
/**
* @group core
* @group nav
*/
class BP_Tests_Core_Nav_BpGetNavMenuItems extends BP_UnitTestCase {
/**
* @ticket BP7110
*/
public function test_top_level_link_should_point_to_displayed_user_for_loggedin_user() {
$users = self::factory()->user->create_many( 2 );
$this->set_current_user( $users[0] );
$user_1_domain = bp_core_get_user_domain( $users[1] );
$this->go_to( $user_1_domain );
$found = bp_get_nav_menu_items();
// Find the Activity top-level item.
$activity_item = null;
foreach ( $found as $f ) {
if ( 'activity' === $f->css_id ) {
$activity_item = $f;
break;
}
}
$this->assertSame( trailingslashit( $user_1_domain ) . 'activity/', $activity_item->link );
}
/**
* @ticket BP7110
*/
public function test_top_level_link_should_point_to_displayed_user_for_loggedout_user() {
$user = self::factory()->user->create();
$this->set_current_user( 0 );
$user_domain = bp_core_get_user_domain( $user );
$this->go_to( $user_domain );
$found = bp_get_nav_menu_items();
// Find the Activity top-level item.
$activity_item = null;
foreach ( $found as $f ) {
if ( 'activity' === $f->css_id ) {
$activity_item = $f;
break;
}
}
$this->assertSame( trailingslashit( $user_domain ) . 'activity/', $activity_item->link );
}
}