[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/tests/phpunit/testcases/routing/ -> members.php (source)

   1  <?php
   2  /**
   3   * @group members
   4   * @group routing
   5   */
   6  class BP_Tests_Routing_Members extends BP_UnitTestCase {
   7      protected $old_current_user = 0;
   8  
   9  	public function setUp() {
  10          parent::setUp();
  11  
  12          buddypress()->members->types = array();
  13          $this->old_current_user = get_current_user_id();
  14          $this->set_current_user( self::factory()->user->create( array( 'user_login' => 'paulgibbs', 'role' => 'subscriber' ) ) );
  15      }
  16  
  17  	public function tearDown() {
  18          $this->set_current_user( $this->old_current_user );
  19          parent::tearDown();
  20      }
  21  
  22  	function test_members_directory() {
  23          $this->go_to( bp_get_members_directory_permalink() );
  24          $this->assertEquals( bp_get_members_root_slug(), bp_current_component() );
  25      }
  26  
  27  	function test_member_permalink() {
  28          $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) );
  29          $this->assertTrue( bp_is_my_profile() );
  30      }
  31  
  32      /**
  33       * @ticket BP6475
  34       */
  35      public function test_member_directory_when_nested_under_wp_page() {
  36          $p = self::factory()->post->create( array(
  37              'post_type' => 'page',
  38              'post_name' => 'foo',
  39          ) );
  40  
  41          $members_page = get_page_by_path( 'members' );
  42  
  43          wp_update_post( array(
  44              'ID' => $members_page->ID,
  45              'post_parent' => $p,
  46          ) );
  47  
  48          $members_page_permalink = bp_get_root_domain() . '/foo/members/';
  49          $this->go_to( $members_page_permalink );
  50  
  51          $this->assertTrue( bp_is_members_component() );
  52          $this->assertEquals( '', bp_current_action() );
  53      }
  54  
  55      /**
  56       * @ticket BP6286
  57       * @group member_types
  58       */
  59  	public function test_member_directory_with_member_type() {
  60          bp_register_member_type( 'foo' );
  61          $this->go_to( bp_get_members_directory_permalink() . 'type/foo/' );
  62          $this->assertTrue( bp_is_members_component() );
  63      }
  64  
  65      /**
  66       * @ticket BP6286
  67       * @group member_types
  68       */
  69      public function test_member_directory_with_member_type_should_obey_filtered_type_slug() {
  70          bp_register_member_type( 'foo' );
  71  
  72          add_filter( 'bp_members_member_type_base', array( $this, 'filter_member_type_base' ) );
  73          $this->go_to( bp_get_members_directory_permalink() . 'buddypress-member-type/foo/' );
  74          remove_filter( 'bp_members_member_type_base', array( $this, 'filter_member_type_base' ) );
  75          $this->assertTrue( bp_is_members_component() );
  76      }
  77  
  78  	public function filter_member_type_base( $base ) {
  79          return 'buddypress-member-type';
  80      }
  81  
  82      /**
  83       * @ticket BP6286
  84       * @group member_types
  85       */
  86      public function test_member_directory_with_member_type_that_has_custom_directory_slug() {
  87          bp_register_member_type( 'foo', array( 'has_directory' => 'foos' ) );
  88          $this->go_to( bp_get_members_directory_permalink() . 'type/foos/' );
  89          $this->assertTrue( bp_is_members_component() );
  90      }
  91  
  92      /**
  93       * @ticket BP6286
  94       * @group member_types
  95       */
  96      public function test_member_directory_with_member_type_should_be_overridden_by_member_with_same_nicename() {
  97          $u = self::factory()->user->create( array( 'user_nicename' => 'foo' ) );
  98          bp_register_member_type( 'foo' );
  99          $this->go_to( bp_get_members_directory_permalink() . 'type/foo/' );
 100  
 101          // Remove the following lines when you implement this test.
 102          $this->markTestIncomplete(
 103              'This test has not been implemented yet.'
 104          );
 105      }
 106  
 107      /**
 108       * @ticket BP6286
 109       * @group member_types
 110       */
 111      public function test_member_directory_should_404_for_member_types_that_have_no_directory() {
 112          bp_register_member_type( 'foo', array( 'has_directory' => false ) );
 113          $this->go_to( bp_get_members_directory_permalink() . 'type/foo/' );
 114          $this->assertTrue( is_404() );
 115      }
 116  
 117      /**
 118       * @ticket BP6325
 119       */
 120  	function test_members_shortlink_redirector() {
 121          $shortlink_member_slug = 'me';
 122  
 123          $this->go_to( bp_get_members_directory_permalink() . $shortlink_member_slug );
 124  
 125          $this->assertSame( get_current_user_id(), bp_displayed_user_id() );
 126      }
 127  }


Generated: Sun Dec 22 01:00:54 2024 Cross-referenced by PHPXref 0.7.1