Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/19/2014 07:28:36 PM (11 years ago)
Author:
boonebgorges
Message:

Correct query concatenation for exclude_groups param in BP_XProfile_Group::get()

The previous format was not working properly when passing multiple group ids.

Fixes #5649

Props imath

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/xprofile/class-bp-xprofile-group.php

    r7915 r8430  
    6868        $this->assertSame( $expected, $found );
    6969    }
     70
     71    /**
     72     * @group get_xprofile_groups
     73     */
     74    public function test_get_xprofile_groups() {
     75        $g1 = $this->factory->xprofile_group->create();
     76        $g2 = $this->factory->xprofile_group->create();
     77        $g3 = $this->factory->xprofile_group->create();
     78
     79        $all = BP_XProfile_Group::get();
     80        $all_results = array_map( 'absint', wp_list_pluck( $all, 'id' ) );
     81
     82        $e1 = array( $g1, $g2 );
     83        $groups1 = BP_XProfile_Group::get( array(
     84            'exclude_groups' => implode( ',', $e1 ),
     85        ) );
     86
     87        $r_groups1 = array_map( 'absint', wp_list_pluck( $groups1, 'id' ) );
     88        $found1 = array_diff( $all_results, $r_groups1 );
     89
     90        $this->assertSame( $e1, array_merge( $found1, array() ) );
     91
     92        $e2 = array( $g2, $g3 );
     93        $groups2 = BP_XProfile_Group::get( array(
     94            'exclude_groups' => $e2,
     95        ) );
     96
     97        $r_groups2 = array_map( 'absint', wp_list_pluck( $groups2, 'id' ) );
     98        $found2 = array_diff( $all_results, $r_groups2 );
     99
     100        $this->assertSame( $e2, array_merge( $found2, array() ) );
     101    }
    70102}
Note: See TracChangeset for help on using the changeset viewer.