Changeset 8167
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-notifications/bp-notifications-classes.php
r8154 r8167 320 320 321 321 // is_new 322 if ( ! empty( $args['is_new'] ) ) { 323 $where_conditions['is_new'] = "is_new = 1"; 324 } elseif ( isset( $args['is_new'] ) && ( 0 === $args['is_new'] || false === $args['is_new'] ) ) { 325 $where_conditions['is_new'] = "is_new = 0"; 322 if ( 'both' !== $args['is_new'] ) { 323 if ( ! empty( $args['is_new'] ) ) { 324 $where_conditions['is_new'] = "is_new = 1"; 325 } elseif ( isset( $args['is_new'] ) && ( 0 === $args['is_new'] || false === $args['is_new'] ) ) { 326 $where_conditions['is_new'] = "is_new = 0"; 327 } 326 328 } 327 329 … … 538 540 * @type string|array $component_action Name of the action to 539 541 * filter by. Can be an array of actions. 540 * @type bool $is_new Whether to limit the query to is_new (unread) 541 * notifications. Default: true. 542 * @type bool $is_new Whether to limit to new notifications. True 543 * returns only new notifications, false returns only non-new 544 * notifications. 'both' returns all. Default: true. 542 545 * @type string $search_terms Term to match against component_name 543 546 * or component_action fields. -
trunk/tests/testcases/notifications/class-bp-notifications-notification.php
r8153 r8167 151 151 $this->assertEquals( $expected, $actual ); 152 152 } 153 154 /** 155 * @group is_new 156 */ 157 public function test_is_new_true() { 158 $u = $this->create_user(); 159 $n1 = $this->factory->notification->create( array( 160 'component_name' => 'friends', 161 'user_id' => $u, 162 'is_new' => false, 163 ) ); 164 $n2 = $this->factory->notification->create( array( 165 'component_name' => 'groups', 166 'user_id' => $u, 167 'is_new' => true, 168 ) ); 169 $n3 = $this->factory->notification->create( array( 170 'component_name' => 'messages', 171 'user_id' => $u, 172 'is_new' => true, 173 ) ); 174 175 $n = BP_Notifications_Notification::get( array( 176 'user_id' => $u, 177 'is_new' => true, 178 ) ); 179 180 // Check that the correct items are pulled up 181 $expected = array( $n2, $n3 ); 182 $actual = wp_list_pluck( $n, 'id' ); 183 $this->assertEquals( $expected, $actual ); 184 } 185 186 /** 187 * @group is_new 188 */ 189 public function test_is_new_false() { 190 $u = $this->create_user(); 191 $n1 = $this->factory->notification->create( array( 192 'component_name' => 'friends', 193 'user_id' => $u, 194 'is_new' => false, 195 ) ); 196 $n2 = $this->factory->notification->create( array( 197 'component_name' => 'groups', 198 'user_id' => $u, 199 'is_new' => true, 200 ) ); 201 $n3 = $this->factory->notification->create( array( 202 'component_name' => 'messages', 203 'user_id' => $u, 204 'is_new' => true, 205 ) ); 206 207 $n = BP_Notifications_Notification::get( array( 208 'user_id' => $u, 209 'is_new' => false, 210 ) ); 211 212 // Check that the correct items are pulled up 213 $expected = array( $n1 ); 214 $actual = wp_list_pluck( $n, 'id' ); 215 $this->assertEquals( $expected, $actual ); 216 } 217 218 /** 219 * @group is_new 220 */ 221 public function test_is_new_both() { 222 $u = $this->create_user(); 223 $n1 = $this->factory->notification->create( array( 224 'component_name' => 'friends', 225 'user_id' => $u, 226 'is_new' => false, 227 ) ); 228 $n2 = $this->factory->notification->create( array( 229 'component_name' => 'groups', 230 'user_id' => $u, 231 'is_new' => true, 232 ) ); 233 $n3 = $this->factory->notification->create( array( 234 'component_name' => 'messages', 235 'user_id' => $u, 236 'is_new' => true, 237 ) ); 238 239 $n = BP_Notifications_Notification::get( array( 240 'user_id' => $u, 241 'is_new' => 'both', 242 ) ); 243 244 // Check that the correct items are pulled up 245 $expected = array( $n1, $n2, $n3 ); 246 $actual = wp_list_pluck( $n, 'id' ); 247 $this->assertEquals( $expected, $actual ); 248 } 153 249 }
Note: See TracChangeset
for help on using the changeset viewer.