From 81e1001d59ac0abe81f1673ade12a03b6ef6e8ed Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sun, 4 Mar 2007 05:35:47 +0000 Subject: [PATCH] More coverage tests. With the exception of the deprecated identifier method, User.pm is 100% covered --- t/User.t | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/t/User.t b/t/User.t index de2d9da57..4d7d0ceb6 100644 --- a/t/User.t +++ b/t/User.t @@ -20,7 +20,7 @@ use WebGUI::Cache; use WebGUI::User; use WebGUI::ProfileField; -use Test::More tests => 90; # increment this value for each test you create +use Test::More tests => 93; # increment this value for each test you create use Test::Deep; my $session = WebGUI::Test->session; @@ -79,6 +79,12 @@ cmp_ok(abs($user->lastUpdated-$lastUpdate), '<=', 1, 'lastUpdated() -- profileFi #Fetching a non-existant profile field returns undef is($user->profileField('notAProfileField'), undef, 'getting non-existant profile fields returns undef'); +################################################################ +# +# authMethods +# +################################################################ + #Let's check the auth methods #Default should be WebGUI @@ -336,7 +342,7 @@ is($clone->username, 'dude', 'newByEmail returns valid user object'); ################################################################ # -# new, cached user profile data +# new, cached user profile data and overrides # ################################################################ @@ -358,6 +364,37 @@ is( $busterCopy->profileField('timeZone'), 'America/Hillsboro', 'busterCopy rece $profileField->set(\%originalFieldData); +$buster->username('mythBuster'); + +my $aliasProfile = WebGUI::ProfileField->new($session, 'alias'); +my %originalAliasProfile = %{ $aliasProfile->get() }; +my %copiedAliasProfile = %originalAliasProfile; +$copiedAliasProfile{'dataDefault'} = "'aliasAlias'"; ##Non word characters; +$aliasProfile->set(\%copiedAliasProfile); + +my $buster3 = WebGUI::User->new($session, $buster->userId); +is($buster3->profileField('alias'), 'aliasAlias', 'default alias set'); + +$copiedAliasProfile{'dataDefault'} = "'....^^^^....'"; ##Non word characters; +$aliasProfile->set(\%copiedAliasProfile); +$buster->uncache(); + +$buster3 = WebGUI::User->new($session, $buster->userId); +is($buster3->profileField('alias'), 'mythBuster', 'alias set to username since the default alias has only non-word characters'); + +$aliasProfile->set(\%originalAliasProfile); + +my %listProfile = %copiedAliasProfile; +$listProfile{'fieldName'} = 'listProfile'; +$listProfile{'dataDefault'} = "['alpha', 'delta', 'tango']"; +my $listProfileField = WebGUI::ProfileField->create($session, 'listProfile', \%listProfile); + +$buster->uncache; +$buster3 = WebGUI::User->new($session, $buster->userId); +is($buster3->profileField('listProfile'), 'alpha', 'profile field with default data value that is a list gives the user the first value'); + +$listProfileField->delete; + ################################################################ # # getGroups @@ -391,6 +428,8 @@ END { $session->config->delete('adminModeSubnets'); $profileField->set(\%originalFieldData); + $aliasProfile->set(\%originalAliasProfile); + $listProfileField->delete; $testCache->flush; $session->db->write(q!delete from userProfileData where userId='1' and fieldName='email'!);