diff options
author | Jim Brandt <jbrandt@bestpractical.com> | 2022-06-16 16:05:40 +0300 |
---|---|---|
committer | Jim Brandt <jbrandt@bestpractical.com> | 2022-06-16 16:05:40 +0300 |
commit | c4052e6e1845f80c79b2f1d32c7b15825553a98b (patch) | |
tree | a13e94d40be130f8f01149ee4d233f31d32cdd7d /t | |
parent | 8cd02c8404e032dc9ed97ce13770d9d0c2a7577c (diff) |
Add tests for LoadOrCreateByEmail
Diffstat (limited to 't')
-rw-r--r-- | t/api/user.t | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/t/api/user.t b/t/api/user.t index 06ef2bf681..0b1c76025a 100644 --- a/t/api/user.t +++ b/t/api/user.t @@ -384,4 +384,32 @@ ok($rqv, "Revoked the right successfully - $rqm"); is $marks[0], $b_ticket->id; } +diag 'Test LoadOrCreateByEmail'; +{ + my $load_user1 = RT::User->new(RT->SystemUser); + my ($id, $msg) = $load_user1->LoadOrCreateByEmail('create-test-1@example.com'); + ok ($id, $msg . ' - ' . $load_user1->EmailAddress); + + my $load_user2 = RT::User->new(RT->SystemUser); + ($id, $msg) = $load_user2->LoadOrCreateByEmail('load-create-test-1@example.com'); + ok ($id, $msg . ' - ' . $load_user2->EmailAddress); + is ($load_user2->Name, 'load-create-test-1@example.com', 'Name set to load-create-test-1@example.com'); + is ($load_user2->EmailAddress, 'load-create-test-1@example.com', 'Email set to load-create-test-1@example.com'); + + my $load_user3 = RT::User->new(RT->SystemUser); + ($id, $msg) = $load_user3->LoadOrCreateByEmail('load-create-test-2@foo.example.com'); + ok ($id, $msg . ' - ' . $load_user3->EmailAddress); + is ($load_user3->Name, 'load-create-test-2@foo.example.com', 'Name set to load-create-test-2@foo.example.com'); + is ($load_user3->EmailAddress, 'load-create-test-2@foo.example.com', 'Email set to load-create-test-2@foo.example.com'); + + RT->Config->Set( CanonicalizeEmailAddressMatch => '@.+\.example\.com' ); + RT->Config->Set( CanonicalizeEmailAddressReplace => '@example.com' ); + + my $load_user4 = RT::User->new(RT->SystemUser); + ($id, $msg) = $load_user4->LoadOrCreateByEmail('load-create-test-3@foo.example.com'); + ok ($id, $msg . ' - ' . $load_user4->EmailAddress); + is ($load_user4->Name, 'load-create-test-3@example.com', 'Name set to load-create-test-3@example.com'); + is ($load_user4->EmailAddress, 'load-create-test-3@example.com', 'Email set to load-create-test-3@example.com'); +} + done_testing(); |