Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/17/2021 08:35:54 PM (9 months ago)
Author:
dcavins
Message:

BP_Invitation: Improve search_terms support for useful columns.

Instead of searching the class column, which would potentially return
surprising results, search the invitee_email and content columns.

Fixes #8443.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/core/invitations.php

    r12428 r12866  
    174174        $this->set_current_user( $old_current_user );
    175175    }
    176    
     176
    177177    public function test_bp_invitations_add_request_vanilla() {
    178178        $old_current_user = get_current_user_id();
     
    288288    }
    289289
     290    public function test_bp_invitations_get_by_search_terms() {
     291        $old_current_user = get_current_user_id();
     292
     293        $u1 = $this->factory->user->create();
     294        $u2 = $this->factory->user->create();
     295        $this->set_current_user( $u1 );
     296
     297        $invites_class = new BPTest_Invitation_Manager_Extension();
     298
     299        // Create an invitation.
     300        $i1_args = array(
     301            'user_id'    => $u2,
     302            'inviter_id' => $u1,
     303            'item_id'    => 1,
     304            'content'    => 'Sometimes, the mystery is enough.',
     305        );
     306        $i1 = $invites_class->add_invitation( $i1_args );
     307        $invites_class->send_invitation_by_id( $i1 );
     308
     309        // Create an invitation that uses an email address.
     310        $i2_args = array(
     311            'invitee_email' => 'findme@buddypress.org',
     312            'inviter_id'    => $u1,
     313            'item_id'       => 1,
     314        );
     315        $i2 = $invites_class->add_invitation( $i2_args );
     316        $invites_class->send_invitation_by_id( $i2 );
     317
     318        $get_invites = array(
     319            'search_terms' => 'mystery',
     320            'fields'       => 'ids',
     321        );
     322        $invites = $invites_class->get_invitations( $get_invites );
     323        $this->assertEqualSets( array( $i1 ), $invites );
     324
     325        $get_invites = array(
     326            'search_terms' => 'findme',
     327            'fields'       => 'ids',
     328        );
     329        $invites = $invites_class->get_invitations( $get_invites );
     330        $this->assertEqualSets( array( $i2 ), $invites );
     331
     332        $this->set_current_user( $old_current_user );
     333    }
     334
    290335}
Note: See TracChangeset for help on using the changeset viewer.