Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

more tests

  • Loading branch information...
commit 2ca1a45a1726faf5c3675e7f375deb4a0364c606 1 parent dedd1e0
@ruz ruz authored
Showing with 95 additions and 1 deletion.
  1. +95 −1 t/fix_users.t
View
96 t/fix_users.t
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use CPAN2RT::Test tests => 28;
+use CPAN2RT::Test tests => 38;
my $test_class = 'CPAN2RT::Test';
ok( my $importer = CPAN2RT->new( ), "created importer" );
@@ -22,6 +22,10 @@ ok( my $importer = CPAN2RT->new( ), "created importer" );
is( $user->Name, 'A', 'Name is correct' );
is( $user->RealName, 'A A', 'Real name updated' );
is( $user->EmailAddress, 'A@cpan.org', 'Email address is set to cpan\'s' );
+
+ $user = RT::User->new( $RT::SystemUser );
+ $user->LoadByEmail('A@xxx.com');
+ ok(!$user->id, "no user by public email");
}
# user has email and it's no his cpan's
@@ -87,3 +91,93 @@ ok( my $importer = CPAN2RT->new( ), "created importer" );
ok(!$user->id, "no more fake user");
}
+# good 'E' user with E@cpan.org email
+{
+ my $user = $test_class->load_or_create_user(
+ Name => 'E',
+ EmailAddress => 'E@cpan.org',
+ Privileged => 1,
+ );
+ $importer->load_or_create_user(
+ E => 'E E' => 'E@xxx.com',
+ );
+ $user = RT::User->new( $RT::SystemUser );
+ $user->Load('E');
+ is( $user->Name, 'E', 'Name is correct' );
+ is( $user->RealName, 'E E', 'Real name updated' );
+ is( $user->EmailAddress, 'E@cpan.org', 'Email address is correct' );
+
+ $user = RT::User->new( $RT::SystemUser );
+ $user->LoadByEmail('E@xxx.com');
+ ok(!$user->id, "no user by public email");
+}
+
+# no user at all
+{
+ $importer->load_or_create_user(
+ F => 'F F' => 'F@xxx.com',
+ );
+ my $user = RT::User->new( $RT::SystemUser );
+ $user->Load('F');
+ is( $user->Name, 'F', 'Name is correct' );
+ is( $user->RealName, 'F F', 'Real is set' );
+ is( $user->EmailAddress, 'F@cpan.org', 'Email address is correct' );
+
+ $user = RT::User->new( $RT::SystemUser );
+ $user->LoadByEmail('F@xxx.com');
+ ok(!$user->id, "no user by public email");
+}
+
+# 'G' user with some email and G@cpan.org user with G@cpan.org email
+{
+ my $user = $test_class->load_or_create_user(
+ Name => 'G',
+ EmailAddress => 'G@xxx.com',
+ Privileged => 1,
+ );
+ $user = $test_class->load_or_create_user(
+ Name => 'G@cpan.org',
+ EmailAddress => 'G@cpan.org',
+ Privileged => 1,
+ );
+
+ $importer->load_or_create_user(
+ G => 'G G' => 'G@xxx.com',
+ );
+ $user = RT::User->new( $RT::SystemUser );
+ $user->Load('G');
+ is( $user->Name, 'G', 'Name is correct' );
+ is( $user->RealName, 'G G', 'Real name updated' );
+ is( $user->EmailAddress, 'G@xxx.com', 'Email address is correct' );
+
+ my $muser = RT::User->new( $RT::SystemUser );
+ $muser->LoadByEmail('G@cpan.org');
+ is($muser->id, $user->id, "users are merged");
+}
+
+# 'H' user with no email and H@cpan.org user with H@cpan.org email
+{
+ my $user = $test_class->load_or_create_user(
+ Name => 'H',
+ Privileged => 1,
+ );
+ $user = $test_class->load_or_create_user(
+ Name => 'H@cpan.org',
+ EmailAddress => 'H@cpan.org',
+ Privileged => 1,
+ );
+
+ $importer->load_or_create_user(
+ H => 'H H' => 'H@xxx.com',
+ );
+ $user = RT::User->new( $RT::SystemUser );
+ $user->Load('H');
+ is( $user->Name, 'H', 'Name is correct' );
+ is( $user->RealName, 'H H', 'Real name updated' );
+ is( $user->EmailAddress, 'H@cpan.org', 'Email address is correct' );
+
+ my $muser = RT::User->new( $RT::SystemUser );
+ $muser->LoadByCols( Name => 'H@cpan.org' );
+ is($muser->id, $user->id, "users are merged");
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.