|
Lines 18-24
Link Here
|
| 18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
use Test::More tests => 86; |
21 |
use Test::More tests => 82; |
| 22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
| 23 |
use Test::Warn; |
23 |
use Test::Warn; |
| 24 |
use Test::Exception; |
24 |
use Test::Exception; |
|
Lines 209-261
is( $letters->[0]->{module}, 'my module', 'GetLetters gets the module correctly'
Link Here
|
| 209 |
is( $letters->[0]->{code}, 'my code', 'GetLetters gets the code correctly' ); |
209 |
is( $letters->[0]->{code}, 'my code', 'GetLetters gets the code correctly' ); |
| 210 |
is( $letters->[0]->{name}, 'my name', 'GetLetters gets the name correctly' ); |
210 |
is( $letters->[0]->{name}, 'my name', 'GetLetters gets the name correctly' ); |
| 211 |
|
211 |
|
| 212 |
|
|
|
| 213 |
# getletter |
| 214 |
subtest 'getletter' => sub { |
| 215 |
plan tests => 16; |
| 216 |
t::lib::Mocks::mock_preference('IndependentBranches', 0); |
| 217 |
my $letter = C4::Letters::getletter('my module', 'my code', $library->{branchcode}, 'email'); |
| 218 |
is( $letter->{branchcode}, $library->{branchcode}, 'GetLetters gets the branch code correctly' ); |
| 219 |
is( $letter->{module}, 'my module', 'GetLetters gets the module correctly' ); |
| 220 |
is( $letter->{code}, 'my code', 'GetLetters gets the code correctly' ); |
| 221 |
is( $letter->{name}, 'my name', 'GetLetters gets the name correctly' ); |
| 222 |
is( $letter->{is_html}, 1, 'GetLetters gets the boolean is_html correctly' ); |
| 223 |
is( $letter->{title}, $title, 'GetLetters gets the title correctly' ); |
| 224 |
is( $letter->{content}, $content, 'GetLetters gets the content correctly' ); |
| 225 |
is( $letter->{message_transport_type}, 'email', 'GetLetters gets the message type correctly' ); |
| 226 |
|
| 227 |
t::lib::Mocks::mock_userenv({ branchcode => "anotherlib", flags => 1 }); |
| 228 |
|
| 229 |
t::lib::Mocks::mock_preference('IndependentBranches', 1); |
| 230 |
$letter = C4::Letters::getletter('my module', 'my code', $library->{branchcode}, 'email'); |
| 231 |
is( $letter->{branchcode}, $library->{branchcode}, 'GetLetters gets the branch code correctly' ); |
| 232 |
is( $letter->{module}, 'my module', 'GetLetters gets the module correctly' ); |
| 233 |
is( $letter->{code}, 'my code', 'GetLetters gets the code correctly' ); |
| 234 |
is( $letter->{name}, 'my name', 'GetLetters gets the name correctly' ); |
| 235 |
is( $letter->{is_html}, 1, 'GetLetters gets the boolean is_html correctly' ); |
| 236 |
is( $letter->{title}, $title, 'GetLetters gets the title correctly' ); |
| 237 |
is( $letter->{content}, $content, 'GetLetters gets the content correctly' ); |
| 238 |
is( $letter->{message_transport_type}, 'email', 'GetLetters gets the message type correctly' ); |
| 239 |
}; |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
# Regression test for Bug 14206 |
| 244 |
$dbh->do( q|INSERT INTO letter(branchcode,module,code,name,is_html,title,content,message_transport_type) VALUES ('FFL','my module','my code','my name',1,?,?,'print')|, undef, $title, $content ); |
| 245 |
my $letter14206_a = C4::Letters::getletter('my module', 'my code', 'FFL' ); |
| 246 |
is( $letter14206_a->{message_transport_type}, 'print', 'Bug 14206 - message_transport_type not passed, correct mtt detected' ); |
| 247 |
my $letter14206_b = C4::Letters::getletter('my module', 'my code', 'FFL', 'print'); |
| 248 |
is( $letter14206_b->{message_transport_type}, 'print', 'Bug 14206 - message_transport_type passed, correct mtt detected' ); |
| 249 |
|
| 250 |
# test for overdue_notices.pl |
| 251 |
my $overdue_rules = { |
| 252 |
letter1 => 'my code', |
| 253 |
}; |
| 254 |
my $i = 1; |
| 255 |
my $branchcode = 'FFL'; |
| 256 |
my $letter14206_c = C4::Letters::getletter('my module', $overdue_rules->{"letter$i"}, $branchcode); |
| 257 |
is( $letter14206_c->{message_transport_type}, 'print', 'Bug 14206 - correct mtt detected for call from overdue_notices.pl' ); |
| 258 |
|
| 259 |
# GetPreparedLetter |
212 |
# GetPreparedLetter |
| 260 |
t::lib::Mocks::mock_preference('OPACBaseURL', 'http://thisisatest.com'); |
213 |
t::lib::Mocks::mock_preference('OPACBaseURL', 'http://thisisatest.com'); |
| 261 |
t::lib::Mocks::mock_preference( 'SendAllEmailsTo', '' ); |
214 |
t::lib::Mocks::mock_preference( 'SendAllEmailsTo', '' ); |