Changeset 8829
- Timestamp:
- 08/13/2014 07:27:20 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-classes.php
r8827 r8829 766 766 } 767 767 768 if ( ! empty( $r['per_page'] ) && ! empty( $r['page'] ) ) {768 if ( ! empty( $r['per_page'] ) && ! empty( $r['page'] ) && $r['per_page'] != -1 ) { 769 769 $sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $r['page'] - 1 ) * $r['per_page']), intval( $r['per_page'] ) ); 770 770 } -
trunk/tests/phpunit/testcases/groups/class-bp-groups-group.php
r8499 r8829 339 339 } 340 340 341 /** 342 * @group get 343 * @ticket BP5477 344 */ 345 public function test_get_groups_page_perpage_params() { 346 // Create more than 20 groups (20 is the default per_page number) 347 $group_ids = array(); 348 349 for ( $i = 1; $i <= 25; $i++ ) { 350 $group_ids[] = $this->factory->group->create(); 351 } 352 353 // Tests 354 // Passing false to 'per_page' and 'page' should result in pagination not being applied 355 $groups = BP_Groups_Group::get( array( 356 'per_page' => false, 357 'page' => false 358 ) ); 359 360 // Should return all groups; "paged" group total should be 25 361 $this->assertEquals( count( $group_ids ), count( $groups['groups'] ) ); 362 363 unset( $groups ); 364 365 // Passing 'per_page' => -1 should result in pagination not being applied. 366 $groups = BP_Groups_Group::get( array( 367 'per_page' => -1 368 ) ); 369 370 // Should return all groups; "paged" group total should match 25 371 $this->assertEquals( count( $group_ids ), count( $groups['groups'] ) ); 372 373 unset( $groups ); 374 375 // If "per_page" and "page" are both set, should result in pagination being applied. 376 $groups = BP_Groups_Group::get( array( 377 'per_page' => 12, 378 'page' => 1 379 ) ); 380 381 // Should return top 12 groups only 382 $this->assertEquals( '12', count( $groups['groups'] ) ); 383 } 384 341 385 /** convert_type_to_order_orderby() **********************************/ 342 386
Note: See TracChangeset
for help on using the changeset viewer.