Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/13/2016 06:21:10 PM (10 years ago)
Author:
dcavins
Message:

Add query support for hierarchical groups.

Adds a new column to the groups table, parent_id, and support for
querying by parent_id via groups_get_groups() and
bp_has_groups().

Does not add any front-facing hierarchy functionality—that is left for
now to plugins.

Props dcavins, boonebgorges, r-a-y, djpaul, mercime.

See #3961.

File:
1 edited

Legend:

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

    r11091 r11095  
    635635                $this->assertEquals( 0, groups_get_invite_count_for_user( $u2 ) );
    636636        }
     637
     638        /**
     639         * @group hierarchical_groups
     640         */
     641        public function test_update_orphaned_groups_on_group_delete_top_level() {
     642                $g1 = $this->factory->group->create();
     643                $g2 = $this->factory->group->create( array(
     644                        'parent_id' => $g1,
     645                ) );
     646
     647                groups_delete_group( $g1 );
     648
     649                $child = groups_get_group( array( 'group_id' => $g2 ) );
     650                $this->assertEquals( 0, $child->parent_id );
     651        }
     652
     653        /**
     654         * @group hierarchical_groups
     655         */
     656        public function test_update_orphaned_groups_on_group_delete_two_levels() {
     657                $g1 = $this->factory->group->create();
     658                $g2 = $this->factory->group->create( array(
     659                        'parent_id' => $g1,
     660                ) );
     661                $g3 = $this->factory->group->create( array(
     662                        'parent_id' => $g2,
     663                ) );
     664
     665                groups_delete_group( $g2 );
     666
     667                $child = groups_get_group( array( 'group_id' => $g3 ) );
     668                $this->assertEquals( $g1, $child->parent_id );
     669        }
    637670}
Note: See TracChangeset for help on using the changeset viewer.