Lines 1-72
Link Here
|
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# Copyright Koha development team 2007 |
4 |
# |
5 |
# This file is part of Koha. |
6 |
# |
7 |
# Koha is free software; you can redistribute it and/or modify it |
8 |
# under the terms of the GNU General Public License as published by |
9 |
# the Free Software Foundation; either version 3 of the License, or |
10 |
# (at your option) any later version. |
11 |
# |
12 |
# Koha is distributed in the hope that it will be useful, but |
13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
# GNU General Public License for more details. |
16 |
# |
17 |
# You should have received a copy of the GNU General Public License |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
19 |
|
20 |
use Modern::Perl; |
21 |
|
22 |
use Test::MockModule; |
23 |
use Test::More tests => 3; |
24 |
|
25 |
use t::lib::Mocks; |
26 |
use t::lib::TestBuilder; |
27 |
|
28 |
use Koha::Database; |
29 |
|
30 |
use_ok('C4::Letters', qw( GetLetters )); |
31 |
|
32 |
my $schema = Koha::Database->new->schema; |
33 |
$schema->storage->txn_begin; |
34 |
our $builder = t::lib::TestBuilder->new; |
35 |
|
36 |
subtest 'GetLetters' => sub { |
37 |
plan tests => 2; |
38 |
t::lib::Mocks::mock_preference( 'dateformat', 'metric' ); |
39 |
|
40 |
my $data_1 = { |
41 |
module => 'blah', code => 'ISBN', branchcode => 'NBSI', name => 'book', is_html => 1, title => 'green', |
42 |
content => 'blahblah', lang => 'french' |
43 |
}; |
44 |
my $data_2 = { |
45 |
module => 'blah', code => 'ISSN', branchcode => 'NSSI', name => 'page', is_html => 0, title => 'blue', |
46 |
content => 'bleble', lang => 'american' |
47 |
}; |
48 |
$builder->build_object( { class => 'Koha::Notice::Templates', value => $data_1 } ); |
49 |
$builder->build_object( { class => 'Koha::Notice::Templates', value => $data_2 } ); |
50 |
|
51 |
my $letters = GetLetters( { module => 'blah' } ); |
52 |
is( scalar(@$letters), 2, 'GetLetters returns the 2 inserted letters' ); |
53 |
|
54 |
my ($ISBN_letter) = grep { $_->{code} eq 'ISBN' } @$letters; |
55 |
is( $ISBN_letter->{name}, 'book', 'letter name for "ISBN" letter is book' ); |
56 |
}; |
57 |
|
58 |
subtest '_parseletter' => sub { |
59 |
plan tests => 2; |
60 |
|
61 |
# Regression test for bug 10843 |
62 |
# $dt->add takes a scalar, not undef |
63 |
my $letter; |
64 |
t::lib::Mocks::mock_preference( 'ReservesMaxPickUpDelay', undef ); |
65 |
$letter = C4::Letters::_parseletter( undef, 'reserves', { waitingdate => "2013-01-01" } ); |
66 |
is( ref($letter), 'HASH' ); |
67 |
t::lib::Mocks::mock_preference( 'ReservesMaxPickUpDelay', 1 ); |
68 |
$letter = C4::Letters::_parseletter( undef, 'reserves', { waitingdate => "2013-01-01" } ); |
69 |
is( ref($letter), 'HASH' ); |
70 |
}; |
71 |
|
72 |
$schema->storage->txn_begin; |