Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 76; |
20 |
use Test::More tests => 79; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
use Test::Warn; |
22 |
use Test::Warn; |
23 |
|
23 |
|
Lines 1813-1815
subtest '_Findgroupreserves' => sub {
Link Here
|
1813 |
|
1813 |
|
1814 |
$schema->txn_rollback; |
1814 |
$schema->txn_rollback; |
1815 |
}; |
1815 |
}; |
1816 |
- |
1816 |
|
|
|
1817 |
subtest 'HOLDDGST tests' => sub { |
1818 |
|
1819 |
plan tests => 2; |
1820 |
$schema->storage->txn_begin; |
1821 |
|
1822 |
my $branch = $builder->build_object({ |
1823 |
class => 'Koha::Libraries', |
1824 |
value => { |
1825 |
branchemail => 'branch@e.mail', |
1826 |
branchreplyto => 'branch@reply.to', |
1827 |
pickup_location => 1 |
1828 |
} |
1829 |
}); |
1830 |
my $item = $builder->build_sample_item({ |
1831 |
homebranch => $branch->branchcode, |
1832 |
holdingbranch => $branch->branchcode |
1833 |
}); |
1834 |
my $item2 = $builder->build_sample_item({ |
1835 |
homebranch => $branch->branchcode, |
1836 |
holdingbranch => $branch->branchcode |
1837 |
}); |
1838 |
|
1839 |
my $wants_hold_and_email = { |
1840 |
wants_digest => '1', |
1841 |
transports => { |
1842 |
sms => 'HOLDDGST', |
1843 |
email => 'HOLDDGST', |
1844 |
}, |
1845 |
letter_code => 'HOLDDGST' |
1846 |
}; |
1847 |
|
1848 |
my $mp = Test::MockModule->new( 'C4::Members::Messaging' ); |
1849 |
|
1850 |
$mp->mock("GetMessagingPreferences",$wants_hold_and_email); |
1851 |
|
1852 |
$dbh->do('DELETE FROM letter'); |
1853 |
|
1854 |
my $email_hold_notice = $builder->build({ |
1855 |
source => 'Letter', |
1856 |
value => { |
1857 |
message_transport_type => 'email', |
1858 |
branchcode => '', |
1859 |
code => 'HOLDDGST', |
1860 |
module => 'reserves', |
1861 |
lang => 'default', |
1862 |
} |
1863 |
}); |
1864 |
|
1865 |
my $sms_hold_notice = $builder->build({ |
1866 |
source => 'Letter', |
1867 |
value => { |
1868 |
message_transport_type => 'sms', |
1869 |
branchcode => '', |
1870 |
code => 'HOLDDGST', |
1871 |
module => 'reserves', |
1872 |
lang=>'default', |
1873 |
} |
1874 |
}); |
1875 |
|
1876 |
my $hold_borrower = $builder->build({ |
1877 |
source => 'Borrower', |
1878 |
value => { |
1879 |
smsalertnumber=>'5555555551', |
1880 |
email=>'a@c.com', |
1881 |
} |
1882 |
})->{borrowernumber}; |
1883 |
|
1884 |
C4::Reserves::AddReserve( |
1885 |
{ |
1886 |
branchcode => $item->homebranch, |
1887 |
borrowernumber => $hold_borrower, |
1888 |
biblionumber => $item->biblionumber, |
1889 |
} |
1890 |
); |
1891 |
|
1892 |
C4::Reserves::AddReserve( |
1893 |
{ |
1894 |
branchcode => $item2->homebranch, |
1895 |
borrowernumber => $hold_borrower, |
1896 |
biblionumber => $item2->biblionumber, |
1897 |
} |
1898 |
); |
1899 |
|
1900 |
ModReserveAffect($item->itemnumber, $hold_borrower, 0); |
1901 |
ModReserveAffect($item2->itemnumber, $hold_borrower, 0); |
1902 |
|
1903 |
my $sms_count = $schema->resultset('MessageQueue')->search({ |
1904 |
letter_code => 'HOLDDGST', |
1905 |
message_transport_type => 'sms', |
1906 |
borrowernumber => $hold_borrower, |
1907 |
})->count; |
1908 |
is($sms_count, 1 ,"Only one sms hold digest message created for two holds"); |
1909 |
|
1910 |
my $email_count = $schema->resultset('MessageQueue')->search({ |
1911 |
letter_code => 'HOLDDGST', |
1912 |
message_transport_type => 'email', |
1913 |
borrowernumber => $hold_borrower, |
1914 |
})->count; |
1915 |
is($email_count, 1 ,"Only one email hold digest message created for two holds"); |
1916 |
|
1917 |
$schema->txn_rollback; |
1918 |
}; |