Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/26/2016 03:13:24 AM (3 years ago)
Author:
dcavins
Message:

Improve backward compatibility in groups_get_group().

In r11090, we changed the signature of groups_get_group() to accept
an integer and added backcompat for the most commonly used former
signature, an associative array. However, it was also possible to use a
query-string-style argument. This commit covers that case.

Fixes #7302.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/groups/functions.php

    r11095 r11213  
    668668        $this->assertEquals( $g1, $child->parent_id );
    669669    }
     670
     671    /**
     672     * @group groups_get_group
     673     * @ticket BP7302
     674     */
     675    public function test_groups_get_group_accept_integer() {
     676        $g1 = $this->factory->group->create();
     677        $group = groups_get_group( $g1 );
     678
     679        $this->assertEquals( $g1, $group->id );
     680    }
     681
     682    /**
     683     * @group groups_get_group
     684     * @ticket BP7302
     685     */
     686    public function test_groups_get_group_accept_numeric() {
     687        $g1 = $this->factory->group->create();
     688        $group = groups_get_group( (string) $g1 );
     689
     690        $this->assertEquals( $g1, $group->id );
     691    }
     692
     693    /**
     694     * @group groups_get_group
     695     * @ticket BP7302
     696     */
     697    public function test_groups_get_group_accept_array() {
     698        $g1 = $this->factory->group->create();
     699        $group = groups_get_group( array( 'group_id' => $g1 ) );
     700
     701        $this->assertEquals( $g1, $group->id );
     702    }
     703
     704    /**
     705     * @group groups_get_group
     706     * @ticket BP7302
     707     */
     708    public function test_groups_get_group_accept_query_string() {
     709        $g1 = $this->factory->group->create();
     710        $group = groups_get_group( 'group_id=' . $g1 );
     711
     712        $this->assertEquals( $g1, $group->id );
     713    }
    670714}
Note: See TracChangeset for help on using the changeset viewer.