| 8 | protected $filter_fired; |
| 9 | protected $current_user; |
| 10 | protected $requesting_user_id; |
| 11 | protected $group; |
| 12 | |
| 13 | public function setUp() { |
| 14 | parent::setUp(); |
| 15 | $this->current_user = get_current_user_id(); |
| 16 | $this->set_current_user( $this->factory->user->create() ); |
| 17 | |
| 18 | $this->requesting_user_id = $this->factory->user->create(); |
| 19 | $this->group = $this->factory->group->create(); |
| 20 | $this->filter_fired = ''; |
| 21 | } |
| 22 | |
| 23 | public function tearDown() { |
| 24 | parent::tearDown(); |
| 25 | $this->set_current_user( $this->current_user ); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * @group groups_format_notifications |
| 30 | */ |
| 31 | public function test_groups_format_notifications_bp_groups_multiple_new_membership_requests_notification() { |
| 32 | add_filter( 'bp_groups_multiple_new_membership_requests_notification', array( $this, 'notification_filter_callback' ) ); |
| 33 | $n = groups_format_notifications( 'new_membership_request', $this->group, $this->requesting_user_id, 5 ); |
| 34 | remove_filter( 'bp_groups_multiple_new_membership_requests_notification', array( $this, 'notification_filter_callback' ) ); |
| 35 | |
| 36 | $this->assertSame( 'bp_groups_multiple_new_membership_requests_notification', $this->filter_fired ); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * @group groups_format_notifications |
| 41 | */ |
| 42 | public function test_groups_format_notifications_bp_groups_single_new_membership_request_notification() { |
| 43 | add_filter( 'bp_groups_single_new_membership_request_notification', array( $this, 'notification_filter_callback' ) ); |
| 44 | $n = groups_format_notifications( 'new_membership_request', $this->group, 0, 1 ); |
| 45 | remove_filter( 'bp_groups_single_new_membership_request_notification', array( $this, 'notification_filter_callback' ) ); |
| 46 | |
| 47 | $this->assertSame( 'bp_groups_single_new_membership_request_notification', $this->filter_fired ); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * @group groups_format_notifications |
| 52 | */ |
| 53 | public function test_groups_format_notifications_bp_groups_multiple_membership_request_accepted_notification() { |
| 54 | add_filter( 'bp_groups_multiple_membership_request_accepted_notification', array( $this, 'notification_filter_callback' ) ); |
| 55 | $n = groups_format_notifications( 'membership_request_accepted', $this->group, 0, 5 ); |
| 56 | remove_filter( 'bp_groups_multiple_membership_request_accepted_notification', array( $this, 'notification_filter_callback' ) ); |
| 57 | |
| 58 | $this->assertSame( 'bp_groups_multiple_membership_request_accepted_notification', $this->filter_fired ); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * @group groups_format_notifications |
| 63 | */ |
| 64 | public function test_groups_format_notifications_bp_groups_single_membership_request_accepted_notification() { |
| 65 | add_filter( 'bp_groups_single_membership_request_accepted_notification', array( $this, 'notification_filter_callback' ) ); |
| 66 | $n = groups_format_notifications( 'membership_request_accepted', $this->group, 0, 1 ); |
| 67 | remove_filter( 'bp_groups_single_membership_request_accepted_notification', array( $this, 'notification_filter_callback' ) ); |
| 68 | |
| 69 | $this->assertSame( 'bp_groups_single_membership_request_accepted_notification', $this->filter_fired ); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * @group groups_format_notifications |
| 74 | */ |
| 75 | public function test_groups_format_notifications_bp_groups_multiple_membership_request_rejected_notification() { |
| 76 | add_filter( 'bp_groups_multiple_membership_request_rejected_notification', array( $this, 'notification_filter_callback' ) ); |
| 77 | $n = groups_format_notifications( 'membership_request_rejected', $this->group, 0, 5 ); |
| 78 | remove_filter( 'bp_groups_multiple_membership_request_rejected_notification', array( $this, 'notification_filter_callback' ) ); |
| 79 | |
| 80 | $this->assertSame( 'bp_groups_multiple_membership_request_rejected_notification', $this->filter_fired ); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * @group groups_format_notifications |
| 85 | */ |
| 86 | public function test_groups_format_notifications_bp_groups_single_membership_request_rejected_notification() { |
| 87 | add_filter( 'bp_groups_single_membership_request_rejected_notification', array( $this, 'notification_filter_callback' ) ); |
| 88 | $n = groups_format_notifications( 'membership_request_rejected', $this->group, 0, 1 ); |
| 89 | remove_filter( 'bp_groups_single_membership_request_rejected_notification', array( $this, 'notification_filter_callback' ) ); |
| 90 | |
| 91 | $this->assertSame( 'bp_groups_single_membership_request_rejected_notification', $this->filter_fired ); |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * @group groups_format_notifications |
| 96 | */ |
| 97 | public function test_groups_format_notifications_bp_groups_multiple_member_promoted_to_admin_notification() { |
| 98 | add_filter( 'bp_groups_multiple_member_promoted_to_admin_notification', array( $this, 'notification_filter_callback' ) ); |
| 99 | $n = groups_format_notifications( 'member_promoted_to_admin', $this->group, 0, 5 ); |
| 100 | remove_filter( 'bp_groups_multiple_member_promoted_to_admin_notification', array( $this, 'notification_filter_callback' ) ); |
| 101 | |
| 102 | $this->assertSame( 'bp_groups_multiple_member_promoted_to_admin_notification', $this->filter_fired ); |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * @group groups_format_notifications |
| 107 | */ |
| 108 | public function test_groups_format_notifications_bp_groups_single_member_promoted_to_admin_notification() { |
| 109 | add_filter( 'bp_groups_single_member_promoted_to_admin_notification', array( $this, 'notification_filter_callback' ) ); |
| 110 | $n = groups_format_notifications( 'member_promoted_to_admin', $this->group, 0, 1 ); |
| 111 | remove_filter( 'bp_groups_single_member_promoted_to_admin_notification', array( $this, 'notification_filter_callback' ) ); |
| 112 | |
| 113 | $this->assertSame( 'bp_groups_single_member_promoted_to_admin_notification', $this->filter_fired ); |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * @group groups_format_notifications |
| 118 | */ |
| 119 | public function test_groups_format_notifications_bp_groups_multiple_member_promoted_to_mod_notification() { |
| 120 | add_filter( 'bp_groups_multiple_member_promoted_to_mod_notification', array( $this, 'notification_filter_callback' ) ); |
| 121 | $n = groups_format_notifications( 'member_promoted_to_mod', $this->group, 0, 5 ); |
| 122 | remove_filter( 'bp_groups_multiple_member_promoted_to_mod_notification', array( $this, 'notification_filter_callback' ) ); |
| 123 | |
| 124 | $this->assertSame( 'bp_groups_multiple_member_promoted_to_mod_notification', $this->filter_fired ); |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * @group groups_format_notifications |
| 129 | */ |
| 130 | public function test_groups_format_notifications_bp_groups_single_member_promoted_to_mod_notification() { |
| 131 | add_filter( 'bp_groups_single_member_promoted_to_mod_notification', array( $this, 'notification_filter_callback' ) ); |
| 132 | $n = groups_format_notifications( 'member_promoted_to_mod', $this->group, 0, 1 ); |
| 133 | remove_filter( 'bp_groups_single_member_promoted_to_mod_notification', array( $this, 'notification_filter_callback' ) ); |
| 134 | |
| 135 | $this->assertSame( 'bp_groups_single_member_promoted_to_mod_notification', $this->filter_fired ); |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * @group groups_format_notifications |
| 140 | */ |
| 141 | public function test_groups_format_notifications_bp_groups_multiple_group_invite_notification() { |
| 142 | add_filter( 'bp_groups_multiple_group_invite_notification', array( $this, 'notification_filter_callback' ) ); |
| 143 | $n = groups_format_notifications( 'group_invite', $this->group, 0, 5 ); |
| 144 | remove_filter( 'bp_groups_multiple_group_invite_notification', array( $this, 'notification_filter_callback' ) ); |
| 145 | |
| 146 | $this->assertSame( 'bp_groups_multiple_group_invite_notification', $this->filter_fired ); |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * @group groups_format_notifications |
| 151 | */ |
| 152 | public function test_groups_format_notifications_bp_groups_single_group_invite_notification() { |
| 153 | add_filter( 'bp_groups_single_group_invite_notification', array( $this, 'notification_filter_callback' ) ); |
| 154 | $n = groups_format_notifications( 'group_invite', $this->group, 0, 1 ); |
| 155 | remove_filter( 'bp_groups_single_group_invite_notification', array( $this, 'notification_filter_callback' ) ); |
| 156 | |
| 157 | $this->assertSame( 'bp_groups_single_group_invite_notification', $this->filter_fired ); |
| 158 | } |
| 159 | |