Apache-Session-MongoDB
view release on metacpan or search on metacpan
t/Apache-Session-MongoDB.t view on Meta::CPAN
%{ Apache::Session::MongoDB->searchOn( $args, "type", "temporary" ) },
4,
"check correct number of temp sessions"
);
my ( $status, $count ) = Apache::Session::MongoDB->deleteIfLowerThan(
$args,
{
not => { 'type' => 'persistent' },
or => {
ttl => 50,
actttl => 50,
}
}
);
is( $status, 1, "reported success" );
is( $count, 3, "3 sessions deleted" );
# Make sure success is correctly returned as a scalar when no job is done
$status = Apache::Session::MongoDB->deleteIfLowerThan(
$args,
{
not => { 'type' => 'persistent' },
or => {
ttl => 50,
actttl => 50,
}
}
);
is( $status, 1, "Status is OK" );
is(
keys
%{ Apache::Session::MongoDB->searchOn( $args, "type", "persistent" )
},
2,
"Check correct number of permanent sessions"
);
is(
keys
%{ Apache::Session::MongoDB->searchOn( $args, "type", "temporary" ) },
1,
"check correct number of temp sessions"
);
# Delete sessions
for (@delSessions) {
my %h;
eval {
tie( %h, 'Apache::Session::MongoDB', $_, $args );
tied(%h)->delete;
}
}
ok( ( tied(%h2)->delete or 1 ), 'Delete session' );
unless ( defined $ENV{MONGODB_USER} and defined $ENV{MONGODB_DB_NAME} ) {
skip 'MONGODB_USER and MONGODB_DB_NAME are not set', 2;
}
for my $w (qw(db_name username password)) {
$args->{$w} = $ENV{ "MONGODB_" . uc($w) };
}
ok( tie( %h, 'Apache::Session::MongoDB', undef, $args ),
'Authentified object' );
ok( ( tied(%h)->delete or 1 ), 'Delete session' );
}
sub newsession {
my ( $args, %data ) = @_;
my %h;
ok( tie( %h, 'Apache::Session::MongoDB', undef, $args ), 'New object' );
for ( keys %data ) {
$h{$_} = $data{$_};
}
my $id = $h{_session_id};
untie(%h);
return $id;
}
( run in 1.966 second using v1.01-cache-2.11-cpan-39bf76dae61 )