Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 77; |
20 |
use Test::More tests => 78; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
use Test::Warn; |
22 |
use Test::Warn; |
23 |
|
23 |
|
Lines 1773-1775
subtest 'DefaultHoldExpiration tests' => sub {
Link Here
|
1773 |
|
1773 |
|
1774 |
$schema->txn_rollback; |
1774 |
$schema->txn_rollback; |
1775 |
}; |
1775 |
}; |
1776 |
- |
1776 |
|
|
|
1777 |
subtest 'HOLDDGST tests' => sub { |
1778 |
|
1779 |
plan tests => 2; |
1780 |
$schema->storage->txn_begin; |
1781 |
|
1782 |
my $branch = $builder->build_object({ |
1783 |
class => 'Koha::Libraries', |
1784 |
value => { |
1785 |
branchemail => 'branch@e.mail', |
1786 |
branchreplyto => 'branch@reply.to', |
1787 |
pickup_location => 1 |
1788 |
} |
1789 |
}); |
1790 |
my $item = $builder->build_sample_item({ |
1791 |
homebranch => $branch->branchcode, |
1792 |
holdingbranch => $branch->branchcode |
1793 |
}); |
1794 |
my $item2 = $builder->build_sample_item({ |
1795 |
homebranch => $branch->branchcode, |
1796 |
holdingbranch => $branch->branchcode |
1797 |
}); |
1798 |
|
1799 |
my $wants_hold_and_email = { |
1800 |
wants_digest => '1', |
1801 |
transports => { |
1802 |
sms => 'HOLDDGST', |
1803 |
email => 'HOLDDGST', |
1804 |
}, |
1805 |
letter_code => 'HOLDDGST' |
1806 |
}; |
1807 |
|
1808 |
my $mp = Test::MockModule->new( 'C4::Members::Messaging' ); |
1809 |
|
1810 |
$mp->mock("GetMessagingPreferences",$wants_hold_and_email); |
1811 |
|
1812 |
$dbh->do('DELETE FROM letter'); |
1813 |
|
1814 |
my $email_hold_notice = $builder->build({ |
1815 |
source => 'Letter', |
1816 |
value => { |
1817 |
message_transport_type => 'email', |
1818 |
branchcode => '', |
1819 |
code => 'HOLDDGST', |
1820 |
module => 'reserves', |
1821 |
lang => 'default', |
1822 |
} |
1823 |
}); |
1824 |
|
1825 |
my $sms_hold_notice = $builder->build({ |
1826 |
source => 'Letter', |
1827 |
value => { |
1828 |
message_transport_type => 'sms', |
1829 |
branchcode => '', |
1830 |
code => 'HOLDDGST', |
1831 |
module => 'reserves', |
1832 |
lang=>'default', |
1833 |
} |
1834 |
}); |
1835 |
|
1836 |
my $hold_borrower = $builder->build({ |
1837 |
source => 'Borrower', |
1838 |
value => { |
1839 |
smsalertnumber=>'5555555551', |
1840 |
email=>'a@c.com', |
1841 |
} |
1842 |
})->{borrowernumber}; |
1843 |
|
1844 |
C4::Reserves::AddReserve( |
1845 |
{ |
1846 |
branchcode => $item->homebranch, |
1847 |
borrowernumber => $hold_borrower, |
1848 |
biblionumber => $item->biblionumber, |
1849 |
} |
1850 |
); |
1851 |
|
1852 |
C4::Reserves::AddReserve( |
1853 |
{ |
1854 |
branchcode => $item2->homebranch, |
1855 |
borrowernumber => $hold_borrower, |
1856 |
biblionumber => $item2->biblionumber, |
1857 |
} |
1858 |
); |
1859 |
|
1860 |
ModReserveAffect($item->itemnumber, $hold_borrower, 0); |
1861 |
ModReserveAffect($item2->itemnumber, $hold_borrower, 0); |
1862 |
|
1863 |
my $sms_count = $schema->resultset('MessageQueue')->search({ |
1864 |
letter_code => 'HOLDDGST', |
1865 |
message_transport_type => 'sms', |
1866 |
borrowernumber => $hold_borrower, |
1867 |
})->count; |
1868 |
is($sms_count, 1 ,"Only one sms hold digest message created for two holds"); |
1869 |
|
1870 |
my $email_count = $schema->resultset('MessageQueue')->search({ |
1871 |
letter_code => 'HOLDDGST', |
1872 |
message_transport_type => 'email', |
1873 |
borrowernumber => $hold_borrower, |
1874 |
})->count; |
1875 |
is($email_count, 1 ,"Only one email hold digest message created for two holds"); |
1876 |
|
1877 |
$schema->txn_rollback; |
1878 |
}; |