[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/tests/phpunit/testcases/friends/ -> notifications.php (source)

   1  <?php
   2  
   3  /**
   4   * @group friends
   5   */
   6  class BP_Tests_Friends_Notifications extends BP_UnitTestcase {
   7      protected $filter_fired;
   8      protected $current_user;
   9      protected $friend;
  10  
  11  	public function setUp() {
  12          parent::setUp();
  13          $this->current_user = get_current_user_id();
  14          $this->set_current_user( self::factory()->user->create() );
  15  
  16          $this->friend = self::factory()->user->create();
  17          $this->filter_fired = '';
  18      }
  19  
  20  	public function tearDown() {
  21          parent::tearDown();
  22          $this->set_current_user( $this->current_user );
  23      }
  24  
  25      /**
  26       * @group friends_format_notifications
  27       */
  28      public function test_friends_format_notifications_bp_friends_multiple_friendship_accepted_notification_filter() {
  29          add_filter( 'bp_friends_multiple_friendship_accepted_notification', array( $this, 'notification_filter_callback' ) );
  30          $n = friends_format_notifications( 'friendship_accepted', $this->friend, 0, 5 );
  31          remove_filter( 'bp_friends_multiple_friendship_accepted_notification', array( $this, 'notification_filter_callback' ) );
  32  
  33          $this->assertSame( 'bp_friends_multiple_friendship_accepted_notification', $this->filter_fired );
  34      }
  35  
  36      /**
  37       * @group friends_format_notifications
  38       */
  39      public function test_friends_format_notifications_bp_friends_single_friendship_accepted_notification_filter() {
  40          add_filter( 'bp_friends_single_friendship_accepted_notification', array( $this, 'notification_filter_callback' ) );
  41          $n = friends_format_notifications( 'friendship_accepted', $this->friend, 0, 1 );
  42          remove_filter( 'bp_friends_single_friendship_accepted_notification', array( $this, 'notification_filter_callback' ) );
  43  
  44          $this->assertSame( 'bp_friends_single_friendship_accepted_notification', $this->filter_fired );
  45      }
  46  
  47      /**
  48       * @group friends_format_notifications
  49       */
  50      public function test_friends_format_notifications_bp_friends_multiple_friendship_request_notification_filter() {
  51          add_filter( 'bp_friends_multiple_friendship_request_notification', array( $this, 'notification_filter_callback' ) );
  52          $n = friends_format_notifications( 'friendship_request', $this->friend, 0, 5 );
  53          remove_filter( 'bp_friends_multiple_friendship_request_notification', array( $this, 'notification_filter_callback' ) );
  54  
  55          $this->assertSame( 'bp_friends_multiple_friendship_request_notification', $this->filter_fired );
  56      }
  57  
  58      /**
  59       * @group friends_format_notifications
  60       */
  61      public function test_friends_format_notifications_bp_friends_single_friendship_request_notification_filter() {
  62          add_filter( 'bp_friends_single_friendship_request_notification', array( $this, 'notification_filter_callback' ) );
  63          $n = friends_format_notifications( 'friendship_request', $this->friend, 0, 1 );
  64          remove_filter( 'bp_friends_single_friendship_request_notification', array( $this, 'notification_filter_callback' ) );
  65  
  66          $this->assertSame( 'bp_friends_single_friendship_request_notification', $this->filter_fired );
  67      }
  68  
  69  	public function notification_filter_callback( $value ) {
  70          $this->filter_fired = current_filter();
  71          return $value;
  72      }
  73  }


Generated: Thu Jul 18 01:01:42 2019 Cross-referenced by PHPXref 0.7.1