[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4   * @group members
   5   * @group member_types
   6   */
   7  class BP_Tests_Members_Template_BpGetMemberTypeDirectoryPermalink extends BP_UnitTestCase {
   8  	public function setUp() {
   9          parent::setUp();
  10  
  11          buddypress()->members->types = array();
  12      }
  13  
  14      /**
  15       * @ticket BP6840
  16       */
  17  	public function test_should_default_to_current_member_type() {
  18          bp_register_member_type( 'foo', array(
  19              'has_directory' => true,
  20          ) );
  21  
  22          add_filter( 'bp_get_current_member_type', array( $this, 'fake_current_member_type' ) );
  23          $found = bp_get_member_type_directory_permalink( 'foo' );
  24          remove_filter( 'bp_get_current_member_type', array( $this, 'fake_current_member_type' ) );
  25  
  26          $this->assertContains( '/type/foo/', $found );
  27      }
  28  
  29      /**
  30       * @ticket BP6840
  31       */
  32      public function test_member_type_param_should_override_current_member_type() {
  33          bp_register_member_type( 'foo', array(
  34              'has_directory' => true,
  35          ) );
  36          bp_register_member_type( 'bar', array(
  37              'has_directory' => true,
  38          ) );
  39  
  40          add_filter( 'bp_get_current_member_type', array( $this, 'fake_current_member_type' ) );
  41          $found = bp_get_member_type_directory_permalink( 'bar' );
  42          remove_filter( 'bp_get_current_member_type', array( $this, 'fake_current_member_type' ) );
  43  
  44          $this->assertContains( '/type/bar/', $found );
  45      }
  46  
  47  	public function fake_current_member_type() {
  48          return 'foo';
  49      }
  50  
  51      /**
  52       * @ticket BP6840
  53       */
  54      public function test_should_return_empty_string_when_type_does_not_exist() {
  55          $this->assertSame( '', bp_get_member_type_directory_permalink( 'foo' ) );
  56      }
  57  
  58      /**
  59       * @ticket BP6840
  60       */
  61      public function test_should_return_empty_string_when_has_directory_is_false_for_type() {
  62          bp_register_member_type( 'foo', array(
  63              'has_directory' => false,
  64          ) );
  65  
  66          $this->assertSame( '', bp_get_member_type_directory_permalink( 'foo' ) );
  67      }
  68  
  69      /**
  70       * @ticket BP6840
  71       */
  72  	public function test_successful_format() {
  73          bp_register_member_type( 'foo', array(
  74              'has_directory' => true,
  75          ) );
  76  
  77          $expected = bp_get_members_directory_permalink() . 'type/foo/';
  78  
  79          $this->assertSame( $expected, bp_get_member_type_directory_permalink( 'foo' ) );
  80      }
  81  }


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