Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/17/2017 06:57:15 PM (9 years ago)
Author:
dcavins
Message:

Change signature of groups_edit_base_group_details().

  • Changes the signature of groups_edit_base_group_details() to accept

a single array instead of several arguments.

  • Adds the capability to update the group slug, with the old slug being

stored as a group meta item.

See #6014.

File:
1 edited

Legend:

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

    r11213 r11555  
    712712                $this->assertEquals( $g1, $group->id );
    713713        }
     714
     715        /**
     716         * @expectedDeprecated groups_edit_base_group_details
     717         * @group groups_edit_base_group_details
     718         */
     719        public function test_groups_edit_base_group_details_test_backcompat_arguments() {
     720                $g1 = $this->factory->group->create();
     721                $name = 'Great Scott';
     722                $description = 'A must-see in time for the holidays!';
     723                groups_edit_base_group_details( $g1, $name, $description, false );
     724
     725                $expected = array(
     726                        'id'          => $g1,
     727                        'name'        => $name,
     728                        'description' => $description
     729                );
     730                $updated_group_object = groups_get_group( $g1 );
     731                $updated = array(
     732                        'id'          => $updated_group_object->id,
     733                        'name'        => $updated_group_object->name,
     734                        'description' => $updated_group_object->description
     735                );
     736
     737                $this->assertEqualSets( $expected, $updated );
     738        }
     739
     740        /**
     741         * @group groups_edit_base_group_details
     742         */
     743        public function test_groups_edit_base_group_details_test_new_arguments() {
     744                $g1 = $this->factory->group->create();
     745                $name = 'Great Scott';
     746                $slug = 'what-about-it';
     747                $description = 'A must-see in time for the holidays!';
     748                groups_edit_base_group_details( array(
     749                                'group_id'       => $g1,
     750                                'name'           => $name,
     751                                'slug'           => $slug,
     752                                'description'    => $description,
     753                                'notify_members' => false,
     754                ) );
     755
     756                $expected = array(
     757                        'id'          => $g1,
     758                        'slug'        => $slug,
     759                        'name'        => $name,
     760                        'description' => $description
     761                );
     762                $updated_group_object = groups_get_group( $g1 );
     763                $updated = array(
     764                        'id'          => $updated_group_object->id,
     765                        'slug'        => $updated_group_object->slug,
     766                        'name'        => $updated_group_object->name,
     767                        'description' => $updated_group_object->description
     768                );
     769
     770                $this->assertEqualSets( $expected, $updated );
     771        }
     772
     773        /**
     774         * @group groups_edit_base_group_details
     775         */
     776        public function test_groups_edit_base_group_details_avoid_slug_collisions() {
     777                $slug = 'circe';
     778                $g1 = $this->factory->group->create( array( 'slug' => $slug ) );
     779                $g2 = $this->factory->group->create( array( 'slug' => 'loom' ) );
     780
     781                // Attempt to use a duplicate slug.
     782                groups_edit_base_group_details( array(
     783                                'group_id'       => $g2,
     784                                'slug'           => $slug,
     785                ) );
     786
     787                $updated_group_object = groups_get_group( $g2 );
     788
     789                $this->assertNotEquals( $slug, $updated_group_object->slug );
     790        }
     791
     792        /**
     793         * @group groups_edit_base_group_details
     794         */
     795        public function test_groups_edit_base_group_details_slug_no_change() {
     796                $slug = 'circe';
     797                $g1 = $this->factory->group->create( array( 'slug' => $slug ) );
     798
     799                // Make sure the slug doesn't get incremented when there's no change.
     800                groups_edit_base_group_details( array(
     801                                'group_id'       => $g1,
     802                                'slug'           => $slug,
     803                ) );
     804
     805                $updated_group_object = groups_get_group( $g1 );
     806
     807                $this->assertEquals( $slug, $updated_group_object->slug );
     808        }
     809
     810        /**
     811         * @group groups_edit_base_group_details
     812         */
     813        public function test_groups_edit_base_group_details_slug_null_value() {
     814                $slug = 'circe';
     815                $g1 = $this->factory->group->create( array( 'slug' => $slug ) );
     816
     817                // Make sure the slug doesn't get changed when null is passed.
     818                groups_edit_base_group_details( array(
     819                                'group_id'       => $g1,
     820                                'slug'           => null,
     821                ) );
     822
     823                $updated_group_object = groups_get_group( $g1 );
     824
     825                $this->assertEquals( $slug, $updated_group_object->slug );
     826        }
     827
    714828}
Note: See TracChangeset for help on using the changeset viewer.