Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 41; |
22 |
use Test::More tests => 42; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
24 |
use Test::Exception; |
24 |
use Test::Exception; |
25 |
use Test::MockModule; |
25 |
use Test::MockModule; |
Lines 1947-1953
subtest 'anonymize' => sub {
Link Here
|
1947 |
is( $patron2->firstname, undef, 'First name patron2 cleared' ); |
1947 |
is( $patron2->firstname, undef, 'First name patron2 cleared' ); |
1948 |
}; |
1948 |
}; |
1949 |
|
1949 |
|
1950 |
subtest 'send_notice' => sub { |
1950 |
subtest 'queue_notice' => sub { |
1951 |
plan tests => 11; |
1951 |
plan tests => 11; |
1952 |
|
1952 |
|
1953 |
my $dbh = C4::Context->dbh; |
1953 |
my $dbh = C4::Context->dbh; |
Lines 1994-2019
subtest 'send_notice' => sub {
Link Here
|
1994 |
}; |
1994 |
}; |
1995 |
my @mtts = ('email'); |
1995 |
my @mtts = ('email'); |
1996 |
|
1996 |
|
1997 |
is( $patron->send_notice(), undef, "Nothing is done if no params passed"); |
1997 |
is( $patron->queue_notice(), undef, "Nothing is done if no params passed"); |
1998 |
is( $patron->send_notice({ letter_params => $letter_params }),undef, "Nothing done if only letter"); |
1998 |
is( $patron->queue_notice({ letter_params => $letter_params }),undef, "Nothing done if only letter"); |
1999 |
is_deeply( |
1999 |
is_deeply( |
2000 |
$patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2000 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2001 |
{sent => ['email'] }, "Email sent" |
2001 |
{sent => ['email'] }, "Email sent" |
2002 |
); |
2002 |
); |
2003 |
$patron->email("")->store; |
2003 |
$patron->email("")->store; |
2004 |
is_deeply( |
2004 |
is_deeply( |
2005 |
$patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2005 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2006 |
{sent => ['print'],fallback => ['email']}, "Email fallsback to print if no email" |
2006 |
{sent => ['print'],fallback => ['email']}, "Email fallsback to print if no email" |
2007 |
); |
2007 |
); |
2008 |
push @mtts, 'sms'; |
2008 |
push @mtts, 'sms'; |
2009 |
is_deeply( |
2009 |
is_deeply( |
2010 |
$patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2010 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2011 |
{sent => ['print','sms'],fallback => ['email']}, "Email fallsback to print if no email, sms sent" |
2011 |
{sent => ['print','sms'],fallback => ['email']}, "Email fallsback to print if no email, sms sent" |
2012 |
); |
2012 |
); |
2013 |
$patron->smsalertnumber("")->store; |
2013 |
$patron->smsalertnumber("")->store; |
2014 |
my $counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
2014 |
my $counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
2015 |
is_deeply( |
2015 |
is_deeply( |
2016 |
$patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2016 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2017 |
{sent => ['print'],fallback => ['email','sms']}, "Email fallsback to print if no emai, sms fallsback to print if no sms, only one print sent" |
2017 |
{sent => ['print'],fallback => ['email','sms']}, "Email fallsback to print if no emai, sms fallsback to print if no sms, only one print sent" |
2018 |
); |
2018 |
); |
2019 |
is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter+1,"Count of queued notices went up by one"); |
2019 |
is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter+1,"Count of queued notices went up by one"); |
Lines 2023-2038
subtest 'send_notice' => sub {
Link Here
|
2023 |
my $borrower_message_preference_id = $dbh->last_insert_id(undef, undef, "borrower_message_preferences", undef); |
2023 |
my $borrower_message_preference_id = $dbh->last_insert_id(undef, undef, "borrower_message_preferences", undef); |
2024 |
$dbh->do(q|INSERT INTO borrower_message_transport_preferences( borrower_message_preference_id, message_transport_type) VALUES ( ?, ? )|, undef, $borrower_message_preference_id, 'email' ); |
2024 |
$dbh->do(q|INSERT INTO borrower_message_transport_preferences( borrower_message_preference_id, message_transport_type) VALUES ( ?, ? )|, undef, $borrower_message_preference_id, 'email' ); |
2025 |
|
2025 |
|
2026 |
is( $patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts, message_name => 'Hold_Filled' }),undef, "Nothing done if transports and name sent"); |
2026 |
is( $patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts, message_name => 'Hold_Filled' }),undef, "Nothing done if transports and name sent"); |
2027 |
|
2027 |
|
2028 |
$patron->email(q|awesome@ismymiddle.name|)->store; |
2028 |
$patron->email(q|awesome@ismymiddle.name|)->store; |
2029 |
is_deeply( |
2029 |
is_deeply( |
2030 |
$patron->send_notice({ letter_params => $letter_params, message_name => 'Hold_Filled' }), |
2030 |
$patron->queue_notice({ letter_params => $letter_params, message_name => 'Hold_Filled' }), |
2031 |
{sent => ['email'] }, "Email sent when using borrower preferences" |
2031 |
{sent => ['email'] }, "Email sent when using borrower preferences" |
2032 |
); |
2032 |
); |
2033 |
$counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
2033 |
$counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
2034 |
is_deeply( |
2034 |
is_deeply( |
2035 |
$patron->send_notice({ letter_params => $letter_params, message_name => 'Hold_Filled', test_mode => 1 }), |
2035 |
$patron->queue_notice({ letter_params => $letter_params, message_name => 'Hold_Filled', test_mode => 1 }), |
2036 |
{sent => ['email'] }, "Report that email sent when using borrower preferences in test_mode" |
2036 |
{sent => ['email'] }, "Report that email sent when using borrower preferences in test_mode" |
2037 |
); |
2037 |
); |
2038 |
is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter,"Count of queued notices not increased in test mode"); |
2038 |
is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter,"Count of queued notices not increased in test mode"); |
2039 |
- |
|
|