[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/tests/phpunit/testcases/core/ -> class-bp-walker-nav-menu.php (source)

   1  <?php
   2  /**
   3   * @group core
   4   * @group BP_Walker_Nav_Menu
   5   */
   6  class BP_Tests_Walker_Nav_Menu extends BP_UnitTestCase {
   7      protected $reset_user_id;
   8      protected $user_id;
   9  
  10  	public function setUp() {
  11          parent::setUp();
  12  
  13          $this->reset_user_id = get_current_user_id();
  14  
  15          $this->user_id = self::factory()->user->create();
  16          $this->set_current_user( $this->user_id );
  17      }
  18  
  19  	public function tearDown() {
  20          parent::tearDown();
  21          $this->set_current_user( $this->reset_user_id );
  22      }
  23  
  24  	public function test_walk_method() {
  25          $expected = array( 'activity-class', 'xprofile-class' );
  26          $items    = array(
  27              (object) array(
  28                  'component_id' => 'activity',
  29                  'name'         => 'Activity',
  30                  'slug'         => 'activity',
  31                  'link'         => trailingslashit( bp_loggedin_user_domain() . bp_get_activity_slug() ),
  32                  'css_id'       => 'activity',
  33                  'class'        => array( $expected[0] ),
  34              ),
  35              (object) array(
  36                  'component_id' => 'xprofile',
  37                  'name'         => 'Profile',
  38                  'slug'         => 'profile',
  39                  'link'         => trailingslashit( bp_loggedin_user_domain() . bp_get_profile_slug() ),
  40                  'css_id'       => 'xprofile',
  41                  'class'        => array( $expected[1] ),
  42              ),
  43          );
  44          $args = (object) array( 'before' => '', 'link_before' => '', 'after' => '', 'link_after' => '' );
  45          $walker = new BP_Walker_Nav_Menu();
  46          $output = $walker->walk( $items, -1, $args );
  47          preg_match_all( '/class=["\']?([^"\']*)["\' ]/is', $output, $classes );
  48          $this->assertSame( $classes[1], $expected );
  49      }
  50  }


Generated: Tue Mar 19 01:01:09 2024 Cross-referenced by PHPXref 0.7.1