ACME-QuoteDB
view release on metacpan or search on metacpan
t/02-get_quotes.t view on Meta::CPAN
} else {fail 'attribution should not be found' };
eval {
$sq->get_quotes({AttrName => 'chewbaccas momma'});
};
if ($@) {
pass 'ok' if $@ =~ m/attribution not found/;
pass 'ok'; #'now your really asking for trouble';
} else {fail 'attribution should not be found' };
eval { # param mispelled
$sq->get_quotes({Charcter => 'bart'});
};
if ($@) {
pass if $@ =~ m/unsupported argument option passed/;
} else {fail 'should alert user on non existant params' };
#sqlite> select COUNT(*) from quote where attribution_id IN (29,5);
#61 # get all family name wiggum quotes (ralph and clancy)
is scalar @{$sq->get_quotes({AttrName => 'wiggum', Rating => '2-10'})}, 15;
# get 6 random quotes
is scalar @{$sq->get_quotes({Limit => 6})}, 6;
is scalar @{$sq->get_quotes({
Limit => 2,
Rating => '9-10'
})}, 2; # get 2 very funny random quotes
is scalar @{$sq->get_quotes({
AttrName => ' wiggum ',
Rating => ' 4 - 7 ', # opps, 'spacing' out,...
Limit => 2
})}, 2; # get 2 not so funny wiggum quotes
ok $sq->get_quotes({
AttrName => 'comic',
Rating => '7'
})->[0] =~ m/Highlander/;
ok $sq->get_quotes({
AttrName => 'comic',
Rating => '7.0'
})->[0] =~ m/Highlander/;
my $gs = "Big deal! When I was a pup, we got spanked by presidents " .
"'til the cows came home! Grover Cleveland spanked me on " .
"two non-consecutive occasions!\n-- Grandpa Simpson";
is $sq->get_quotes_contain({
Contain => 'til the cow'
})->[0], $gs;
is $sq->get_quotes_contain({
Contain => 'til the cow',
Rating => '1-5',
Limit => 2
})->[0], undef;
eval {
$sq->get_quotes_contain({
Contain => 'til the cow',
Rating => '-7',
Limit => 2
})};
if ($@) {
pass if $@ =~ m/negative range not permitted/;
} else {fail 'should alert user on incorrect rating input' };
is $sq->get_quotes_contain({
Contain => 'wookie',
AttrName => 'ralph',
Limit => 1
})->[0], qq{I bent my wookie.\n-- Ralph Wiggum};
( run in 2.259 seconds using v1.01-cache-2.11-cpan-d80b1682f3f )