Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/23/2021 11:31:33 PM (3 years ago)
Author:
dcavins
Message:

BP_Invitation: Increment date_modified on key actions.

When an invitation is sent or accepted, the date_modified
should be updated. However, if a date_modified has been
specified in the invitation or request creation function
(as we do in our unit test functions), the date_modified
should be set to that, even if notices are sent (now) as
part of the creation process.

Ensure that BP_Invitation::get_query_clauses() handles specified date_modified data updates.

Fixes #8444.

File:
1 edited

Legend:

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

    r12866 r12873  
    333333    }
    334334
     335    public function test_bp_invitations_add_request_with_date_modified() {
     336        $old_current_user = get_current_user_id();
     337
     338        $u1 = $this->factory->user->create();
     339        $this->set_current_user( $u1 );
     340
     341        $invites_class = new BPTest_Invitation_Manager_Extension();
     342
     343        $time = gmdate( 'Y-m-d H:i:s', time() - 100 );
     344        $args = array(
     345            'user_id'           => $u1,
     346            'item_id'           => 7,
     347            'date_modified'     => $time,
     348        );
     349        $r1 = $invites_class->add_request( $args );
     350
     351        $req = new BP_Invitation( $r1 );
     352        $this->assertEquals( $time, $req->date_modified );
     353
     354        $this->set_current_user( $old_current_user );
     355    }
     356
     357    public function test_bp_invitations_add_invite_with_date_modified() {
     358        $old_current_user = get_current_user_id();
     359
     360        $u1 = $this->factory->user->create();
     361        $u2 = $this->factory->user->create();
     362        $this->set_current_user( $u1 );
     363
     364        $invites_class = new BPTest_Invitation_Manager_Extension();
     365        $time = gmdate( 'Y-m-d H:i:s', time() - 100 );
     366
     367        // Create an invitation.
     368        $invite_args = array(
     369            'user_id'           => $u2,
     370            'inviter_id'        => $u1,
     371            'item_id'           => 1,
     372            'send_invite'       => 1,
     373            'date_modified'     => $time,
     374        );
     375        $i1 = $invites_class->add_invitation( $invite_args );
     376
     377        $inv = new BP_Invitation( $i1 );
     378        $this->assertEquals( $time, $inv->date_modified );
     379
     380        $this->set_current_user( $old_current_user );
     381    }
     382
    335383}
Note: See TracChangeset for help on using the changeset viewer.