|
Lines 7-13
use t::lib::TestBuilder;
Link Here
|
| 7 |
|
7 |
|
| 8 |
use C4::Context; |
8 |
use C4::Context; |
| 9 |
|
9 |
|
| 10 |
use Test::More tests => 73; |
10 |
use Test::More tests => 74; |
| 11 |
use Test::Exception; |
11 |
use Test::Exception; |
| 12 |
|
12 |
|
| 13 |
use MARC::Record; |
13 |
use MARC::Record; |
|
Lines 15-21
use MARC::Record;
Link Here
|
| 15 |
use C4::Biblio; |
15 |
use C4::Biblio; |
| 16 |
use C4::Calendar; |
16 |
use C4::Calendar; |
| 17 |
use C4::Items; |
17 |
use C4::Items; |
| 18 |
use C4::Reserves qw( AddReserve CalculatePriority ModReserve ToggleSuspend AutoUnsuspendReserves SuspendAll ModReserveMinusPriority AlterPriority CanItemBeReserved CheckReserves ); |
18 |
use C4::Reserves qw( AddReserve CalculatePriority ModReserve ToggleSuspend AutoUnsuspendReserves SuspendAll ModReserveMinusPriority AlterPriority CanItemBeReserved CheckReserves MoveReserve ); |
| 19 |
use C4::Circulation qw( CanBookBeRenewed ); |
19 |
use C4::Circulation qw( CanBookBeRenewed ); |
| 20 |
|
20 |
|
| 21 |
use Koha::Biblios; |
21 |
use Koha::Biblios; |
|
Lines 1809-1811
subtest 'Koha::Holds->get_items_that_can_fill returns items with datecancelled o
Link Here
|
| 1809 |
|
1809 |
|
| 1810 |
$schema->storage->txn_rollback; |
1810 |
$schema->storage->txn_rollback; |
| 1811 |
}; |
1811 |
}; |
| 1812 |
- |
1812 |
|
|
|
1813 |
subtest 'EmailPatronWhenHoldIsPlaced tests' => sub { |
| 1814 |
plan tests => 2; |
| 1815 |
|
| 1816 |
$schema->storage->txn_begin; |
| 1817 |
|
| 1818 |
my $item = $builder->build_sample_item; |
| 1819 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 1820 |
my $borrowernumber = $patron->id; |
| 1821 |
Koha::CirculationRules->set_rules( |
| 1822 |
{ |
| 1823 |
categorycode => undef, |
| 1824 |
branchcode => undef, |
| 1825 |
itemtype => undef, |
| 1826 |
rules => { |
| 1827 |
reservesallowed => 25, |
| 1828 |
holds_per_record => 99, |
| 1829 |
} |
| 1830 |
} |
| 1831 |
); |
| 1832 |
|
| 1833 |
t::lib::Mocks::mock_preference( 'EmailPatronWhenHoldIsPlaced', 0 ); |
| 1834 |
my $original_notices_count = Koha::Notice::Messages->search( |
| 1835 |
{ |
| 1836 |
letter_code => 'HOLDPLACED_PATRON', |
| 1837 |
to_address => $patron->notice_email_address, |
| 1838 |
} |
| 1839 |
)->count; |
| 1840 |
|
| 1841 |
my $hold_id = AddReserve( |
| 1842 |
{ |
| 1843 |
branchcode => $item->homebranch, |
| 1844 |
borrowernumber => $borrowernumber, |
| 1845 |
biblionumber => $item->biblionumber, |
| 1846 |
itemnumber => $item->itemnumber, |
| 1847 |
} |
| 1848 |
); |
| 1849 |
my $post_notices_count = Koha::Notice::Messages->search( |
| 1850 |
{ |
| 1851 |
letter_code => 'HOLDPLACED_PATRON', |
| 1852 |
to_address => $patron->notice_email_address, |
| 1853 |
} |
| 1854 |
)->count; |
| 1855 |
is( |
| 1856 |
$post_notices_count, $original_notices_count, |
| 1857 |
"EmailPatronWhenHoldIsPlaced is disabled so no email is queued" |
| 1858 |
); |
| 1859 |
MoveReserve( $item->itemnumber, $borrowernumber, 1 ); |
| 1860 |
|
| 1861 |
$original_notices_count = Koha::Notice::Messages->search( |
| 1862 |
{ |
| 1863 |
letter_code => 'HOLDPLACED_PATRON', |
| 1864 |
to_address => $patron->notice_email_address, |
| 1865 |
} |
| 1866 |
)->count; |
| 1867 |
t::lib::Mocks::mock_preference( 'EmailPatronWhenHoldIsPlaced', 1 ); |
| 1868 |
AddReserve( |
| 1869 |
{ |
| 1870 |
branchcode => $item->homebranch, |
| 1871 |
borrowernumber => $borrowernumber, |
| 1872 |
biblionumber => $item->biblionumber, |
| 1873 |
itemnumber => $item->itemnumber, |
| 1874 |
} |
| 1875 |
); |
| 1876 |
$post_notices_count = Koha::Notice::Messages->search( |
| 1877 |
{ |
| 1878 |
letter_code => 'HOLDPLACED_PATRON', |
| 1879 |
to_address => $patron->notice_email_address, |
| 1880 |
} |
| 1881 |
)->count; |
| 1882 |
is( |
| 1883 |
$post_notices_count, |
| 1884 |
$original_notices_count + 1, |
| 1885 |
"EmailPatronWhenHoldIsPlaced is enabled so HOLDPLACED_PATRON email is queued" |
| 1886 |
); |
| 1887 |
|
| 1888 |
$schema->storage->txn_rollback; |
| 1889 |
}; |