From 613de97185e75ec85939b551c9f4af6a39a7c704 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Wed, 18 Oct 2023 21:03:19 +0000 Subject: [PATCH] Bug 8838: (follow-up) Rebase, fix typos, and tidy. Signed-off-by: Emily Lamancusa --- installer/data/mysql/atomicupdate/bug_8838.pl | 14 +- .../mysql/en/mandatory/sample_notices.yml | 2 +- t/db_dependent/Reserves.t | 120 ++++++++++-------- 3 files changed, 78 insertions(+), 58 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_8838.pl b/installer/data/mysql/atomicupdate/bug_8838.pl index 70a230db62..4f3c6698f8 100755 --- a/installer/data/mysql/atomicupdate/bug_8838.pl +++ b/installer/data/mysql/atomicupdate/bug_8838.pl @@ -7,16 +7,20 @@ return { my ($args) = @_; my ( $dbh, $out ) = @$args{qw(dbh out)}; - $dbh->do(q{ - INSERT IGNORE INTO `letter` VALUES (NULL,'reserves','HOLDDGST','','Hold available for pickup (digest)',0,'Hold(s) available for pickup','You have one or more holds available for pickup:\r\n----\r\nTitle: [% hold.biblio.title %]\r\nAuthor: [% hold.biblio.author %]\r\nCopy: [% hold.item.copynumber %]\r\nLocation: [% hold.branch.branchname %]\r\nWaiting since: [% hold.waitingdate %]:\r\n[% hold.branch.branchaddress1 %]\r\n[% hold.branch.branchaddress2 %]\r\n[% hold.branch.branchaddress3 %]\r\n[% hold.branch.branchcity %] [% hold.branch.branchzip %]\r\n----','email','default','2023-08-29 18:42:15'); - }); + $dbh->do( + q{ + INSERT IGNORE INTO `letter` VALUES (NULL,'reserves','HOLDDGST','','Hold available for pickup (digest)',0,'Hold(s) available for pickup','You have one or more holds available for pickup:\r\n----\r\nTitle: [% hold.biblio.title %]\r\nAuthor: [% hold.biblio.author %]\r\nCopy: [% hold.item.copynumber %]\r\nLocation: [% hold.branch.branchname %]\r\nWaiting since: [% hold.waitingdate %]\r\n[% hold.branch.branchaddress1 %]\r\n[% hold.branch.branchaddress2 %]\r\n[% hold.branch.branchaddress3 %]\r\n[% hold.branch.branchcity %] [% hold.branch.branchzip %]\r\n----','email','default','2023-08-29 18:42:15'); + } + ); - $dbh->do(q{ + $dbh->do( + q{ INSERT IGNORE INTO message_transports VALUES ( 4, "email", 1, "reserves", "HOLDDGST", "" ), ( 4, "sms", 1, "reserves", "HOLDDGST", "" ), ( 4, "phone", 1, "reserves", "HOLDDGST", ""); - }); + } + ); # Print useful stuff here # tables diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml index 178e1a02e3..3105ef3519 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.yml +++ b/installer/data/mysql/en/mandatory/sample_notices.yml @@ -1806,7 +1806,7 @@ tables: - "Author: [% hold.biblio.author %]" - "Copy: [% hold.item.copynumber %]" - "Waiting since: [% hold.waitingdate %]" - - "Waitng at: [% hold.branch.branchname %]" + - "Waiting at: [% hold.branch.branchname %]" - "[% hold.branch.branchaddress1 %]" - "[% hold.branch.branchaddress2 %]" - "[% hold.branch.branchaddress3 %]" diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index 0acd22030f..df30b8003a 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 79; +use Test::More tests => 77; use Test::MockModule; use Test::Warn; @@ -1819,67 +1819,79 @@ subtest 'HOLDDGST tests' => sub { plan tests => 2; $schema->storage->txn_begin; - my $branch = $builder->build_object({ - class => 'Koha::Libraries', - value => { - branchemail => 'branch@e.mail', - branchreplyto => 'branch@reply.to', - pickup_location => 1 + my $branch = $builder->build_object( + { + class => 'Koha::Libraries', + value => { + branchemail => 'branch@e.mail', + branchreplyto => 'branch@reply.to', + pickup_location => 1 + } } - }); - my $item = $builder->build_sample_item({ - homebranch => $branch->branchcode, - holdingbranch => $branch->branchcode - }); - my $item2 = $builder->build_sample_item({ - homebranch => $branch->branchcode, - holdingbranch => $branch->branchcode - }); + ); + my $item = $builder->build_sample_item( + { + homebranch => $branch->branchcode, + holdingbranch => $branch->branchcode + } + ); + my $item2 = $builder->build_sample_item( + { + homebranch => $branch->branchcode, + holdingbranch => $branch->branchcode + } + ); my $wants_hold_and_email = { wants_digest => '1', - transports => { - sms => 'HOLDDGST', + transports => { + sms => 'HOLDDGST', email => 'HOLDDGST', - }, + }, letter_code => 'HOLDDGST' }; - my $mp = Test::MockModule->new( 'C4::Members::Messaging' ); + my $mp = Test::MockModule->new('C4::Members::Messaging'); - $mp->mock("GetMessagingPreferences",$wants_hold_and_email); + $mp->mock( "GetMessagingPreferences", $wants_hold_and_email ); $dbh->do('DELETE FROM letter'); - my $email_hold_notice = $builder->build({ + my $email_hold_notice = $builder->build( + { source => 'Letter', - value => { + value => { message_transport_type => 'email', - branchcode => '', - code => 'HOLDDGST', - module => 'reserves', - lang => 'default', + branchcode => '', + code => 'HOLDDGST', + module => 'reserves', + lang => 'default', } - }); + } + ); - my $sms_hold_notice = $builder->build({ + my $sms_hold_notice = $builder->build( + { source => 'Letter', - value => { + value => { message_transport_type => 'sms', - branchcode => '', - code => 'HOLDDGST', - module => 'reserves', - lang=>'default', + branchcode => '', + code => 'HOLDDGST', + module => 'reserves', + lang => 'default', } - }); + } + ); - my $hold_borrower = $builder->build({ + my $hold_borrower = $builder->build( + { source => 'Borrower', - value => { - smsalertnumber=>'5555555551', - email=>'a@c.com', + value => { + smsalertnumber => '5555555551', + email => 'a@c.com', } - })->{borrowernumber}; + } + )->{borrowernumber}; C4::Reserves::AddReserve( { @@ -1897,22 +1909,26 @@ subtest 'HOLDDGST tests' => sub { } ); - ModReserveAffect($item->itemnumber, $hold_borrower, 0); - ModReserveAffect($item2->itemnumber, $hold_borrower, 0); + ModReserveAffect( $item->itemnumber, $hold_borrower, 0 ); + ModReserveAffect( $item2->itemnumber, $hold_borrower, 0 ); - my $sms_count = $schema->resultset('MessageQueue')->search({ - letter_code => 'HOLDDGST', + my $sms_count = $schema->resultset('MessageQueue')->search( + { + letter_code => 'HOLDDGST', message_transport_type => 'sms', - borrowernumber => $hold_borrower, - })->count; - is($sms_count, 1 ,"Only one sms hold digest message created for two holds"); + borrowernumber => $hold_borrower, + } + )->count; + is( $sms_count, 1, "Only one sms hold digest message created for two holds" ); - my $email_count = $schema->resultset('MessageQueue')->search({ - letter_code => 'HOLDDGST', + my $email_count = $schema->resultset('MessageQueue')->search( + { + letter_code => 'HOLDDGST', message_transport_type => 'email', - borrowernumber => $hold_borrower, - })->count; - is($email_count, 1 ,"Only one email hold digest message created for two holds"); + borrowernumber => $hold_borrower, + } + )->count; + is( $email_count, 1, "Only one email hold digest message created for two holds" ); $schema->txn_rollback; }; -- 2.34.1