Class-User-DBI
view release on metacpan or search on metacpan
t/22-cudbi_working_example.t view on Meta::CPAN
[ 'east', 'The Eastern territories' ],
[ 'west', 'The Western territories' ],
[ 'north', 'The Northern territories' ],
[ 'south', 'The Southern territories' ],
),
4,
'Created four domains.'
);
# Now add a user.
my $user = new_ok( 'Class::User::DBI', [ $conn, 'kahn' ] );
ok(
$user->add_user(
{
password => 'The rain in Spain falls mainly on the planes.',
ip_req => 1,
username => 'Ghengis Kahn',
email => 'wreker@havoc.net',
ips => [ '192.168.0.1', '127.0.0.1' ],
role => 'principles',
domains => [qw( east west north south )],
}
),
'Added user "kahn".'
);
ok( $user->exists_user, "Kahn exists." );
ok(
$user->validate(
'The rain in Spain falls mainly on the planes.',
'192.168.0.1'
),
'He validates.'
);
ok( $user->user_domains->has_domain('north'), 'He has a "north" domain.' );
my @domains = $user->user_domains->fetch_domains;
is( scalar @domains, 4, 'He has four domains.' );
ok( $user->is_role('principles'), 'He has the "principles" role.' );
ok( $user->role_privileges->has_privilege('play'),
'He has the "play" privilege.' );
ok(
!$user->role_privileges->has_privilege('watch'),
'He doesn\'t have the "watch" privilege.'
);
my $profile;
is( ref( $profile = $user->load_profile ),
'HASH', 'load_profile returns a hashref.' );
foreach my $key (qw( username email domains role privileges )) {
ok( exists $profile->{$key}, "$key profile attribute exists." );
}
my $credentials;
is( ref( $credentials = $user->get_credentials ),
'HASH', 'get_credentials returns a hashref.' );
foreach my $key (qw( valid_ips ip_required salt_hex userid pass_hex )) {
ok( exists $credentials->{$key}, "$key credentials attribute exists." );
}
ok( $user->delete_user, 'User deleted.' );
ok( !$user->validated, 'User is no longer valid.' );
ok( !$user->exists_user, 'User no longer exists.' );
done_testing();
( run in 0.740 second using v1.01-cache-2.11-cpan-39bf76dae61 )