View | Details | Raw Unified | Return to bug 19743
Collapse All | Expand All

(-)a/t/db_dependent/Letters/TemplateToolkit.t (-2 / +123 lines)
Lines 19-25 Link Here
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
use Test::More tests => 17;
22
use Test::More tests => 18;
23
use Test::Warn;
23
use Test::Warn;
24
24
25
use MARC::Record;
25
use MARC::Record;
Lines 488-493 Thank you for visiting [% branch.branchname %]. Link Here
488
488
489
    };
489
    };
490
490
491
    subtest 'Bug 19743 - Header and Footer should be updated on each item for checkin / checkout / renewal notices' => sub {
492
        plan tests => 8;
493
494
        my $checkout_code = 'CHECKOUT';
495
        my $checkin_code = 'CHECKIN';
496
497
        my $dbh = C4::Context->dbh;
498
        $dbh->do("DELETE FROM letter");
499
500
        # Enable notification for CHECKOUT - Things are hardcoded here but should work with default data
501
        $dbh->do(q|INSERT INTO borrower_message_preferences( borrowernumber, message_attribute_id ) VALUES ( ?, ? )|, undef, $patron->{borrowernumber}, 6 );
502
        my $borrower_message_preference_id = $dbh->last_insert_id(undef, undef, "borrower_message_preferences", undef);
503
        $dbh->do(q|INSERT INTO borrower_message_transport_preferences( borrower_message_preference_id, message_transport_type) VALUES ( ?, ? )|, undef, $borrower_message_preference_id, 'email' );
504
        # Enable notification for CHECKIN - Things are hardcoded here but should work with default data
505
        $dbh->do(q|INSERT INTO borrower_message_preferences( borrowernumber, message_attribute_id ) VALUES ( ?, ? )|, undef, $patron->{borrowernumber}, 5 );
506
        $borrower_message_preference_id = $dbh->last_insert_id(undef, undef, "borrower_message_preferences", undef);
507
        $dbh->do(q|INSERT INTO borrower_message_transport_preferences( borrower_message_preference_id, message_transport_type) VALUES ( ?, ? )|, undef, $borrower_message_preference_id, 'email' );
508
509
        my $checkout_template = q|
510
<<branches.branchname>>
511
----
512
----
513
|;
514
        reset_template( { template => $checkout_template, code => $checkout_code, module => 'circulation' } );
515
        my $checkin_template = q[
516
<<branches.branchname>>
517
----
518
----
519
];
520
        reset_template( { template => $checkin_template, code => $checkin_code, module => 'circulation' } );
521
522
        my $issue = C4::Circulation::AddIssue( $patron, $item1->{barcode} );
523
        my $first_checkout_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next;
524
525
        my $library_object = Koha::Libraries->find( $issue->branchcode );
526
        my $old_branchname = $library_object->branchname;
527
        my $new_branchname = "Kyle M Hall Memorial Library";
528
529
        # Change branch name for second checkout notice
530
        $library_object->branchname($new_branchname);
531
        $library_object->store();
532
533
        C4::Circulation::AddIssue( $patron, $item2->{barcode} );
534
        my $second_checkout_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next;
535
536
        # Restore old name for first checkin notice
537
        $library_object->branchname( $old_branchname );
538
        $library_object->store();
539
540
        AddReturn( $item1->{barcode} );
541
        my $first_checkin_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next;
542
543
        # Change branch name for second checkin notice
544
        $library_object->branchname($new_branchname);
545
        $library_object->store();
546
547
        AddReturn( $item2->{barcode} );
548
        my $second_checkin_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next;
549
550
        # Restore old name for first TT checkout notice
551
        $library_object->branchname( $old_branchname );
552
        $library_object->store();
553
554
        Koha::Notice::Messages->delete;
555
556
        # TT syntax
557
        $checkout_template = q|
558
[% branch.branchname %]
559
----
560
----
561
|;
562
        reset_template( { template => $checkout_template, code => $checkout_code, module => 'circulation' } );
563
        $checkin_template = q[
564
[% branch.branchname %]
565
----
566
----
567
];
568
        reset_template( { template => $checkin_template, code => $checkin_code, module => 'circulation' } );
569
570
        C4::Circulation::AddIssue( $patron, $item1->{barcode} );
571
        my $first_checkout_tt_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next;
572
573
        # Change branch name for second checkout notice
574
        $library_object->branchname($new_branchname);
575
        $library_object->store();
576
577
        C4::Circulation::AddIssue( $patron, $item2->{barcode} );
578
        my $second_checkout_tt_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next;
579
580
        # Restore old name for first checkin notice
581
        $library_object->branchname( $old_branchname );
582
        $library_object->store();
583
584
        AddReturn( $item1->{barcode} );
585
        my $first_checkin_tt_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next;
586
#
587
        # Change branch name for second checkin notice
588
        $library_object->branchname($new_branchname);
589
        $library_object->store();
590
591
        AddReturn( $item2->{barcode} );
592
        my $second_checkin_tt_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next;
593
594
        my $first_letter = qq[
595
$old_branchname
596
];
597
        my $second_letter = qq[
598
$new_branchname
599
];
600
601
602
        is( $first_checkout_letter->content, $first_letter, 'Verify first checkout letter' );
603
        is( $second_checkout_letter->content, $second_letter, 'Verify second checkout letter' );
604
        is( $first_checkin_letter->content, $first_letter, 'Verify first checkin letter'  );
605
        is( $second_checkin_letter->content, $second_letter, 'Verify second checkin letter' );
606
607
        is( $first_checkout_tt_letter->content, $first_letter, 'Verify TT first checkout letter' );
608
        is( $second_checkout_tt_letter->content, $second_letter, 'Verify TT second checkout letter' );
609
        is( $first_checkin_tt_letter->content, $first_letter, 'Verify TT first checkin letter'  );
610
        is( $second_checkin_tt_letter->content, $second_letter, 'Verify TT second checkin letter' );
611
    };
612
491
    subtest 'DUEDGST|count' => sub {
613
    subtest 'DUEDGST|count' => sub {
492
        plan tests => 1;
614
        plan tests => 1;
493
615
494
- 

Return to bug 19743