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