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

(-)a/C4/Message.pm (-4 / +4 lines)
Lines 37-44 How to add a new message to the queue: Link Here
37
37
38
  use C4::Message;
38
  use C4::Message;
39
  use C4::Items;
39
  use C4::Items;
40
  my $borrower = { borrowernumber => 1 };
40
  my $patron = Koha::Patron->find({ borrowernumber => 1 });
41
  my $item     = Koha::Items->find($itemnumber)->unblessed;
41
  my $item   = Koha::Items->find($itemnumber)->unblessed;
42
  my $letter =  C4::Letters::GetPreparedLetter (
42
  my $letter =  C4::Letters::GetPreparedLetter (
43
      module => 'circulation',
43
      module => 'circulation',
44
      letter_code => 'CHECKOUT',
44
      letter_code => 'CHECKOUT',
Lines 48-54 How to add a new message to the queue: Link Here
48
          'biblioitems', $item->{biblionumber},
48
          'biblioitems', $item->{biblionumber},
49
      },
49
      },
50
  );
50
  );
51
  C4::Message->enqueue($letter, $borrower->{borrowernumber}, 'email');
51
  C4::Message->enqueue($letter, $patron, 'email');
52
52
53
How to update a borrower's last checkout message:
53
How to update a borrower's last checkout message:
54
54
Lines 148-154 sub find_last_message { Link Here
148
}
148
}
149
149
150
150
151
=head3 C4::Message->enqueue($letter, $borrower, $transport)
151
=head3 C4::Message->enqueue($letter, $patron, $transport)
152
152
153
This is a front-end for C<C4::Letters::EnqueueLetter()> that adds metadata to
153
This is a front-end for C<C4::Letters::EnqueueLetter()> that adds metadata to
154
the message.
154
the message.
(-)a/t/db_dependent/Message.t (-4 / +12 lines)
Lines 16-26 Link Here
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
use Test::More tests => 3;
19
use Test::More tests => 5;
20
20
21
use utf8;
21
use utf8;
22
22
23
use t::lib::TestBuilder;
23
use t::lib::TestBuilder;
24
use t::lib::Mocks;
24
25
25
use C4::Letters qw( GetPreparedLetter );
26
use C4::Letters qw( GetPreparedLetter );
26
use Koha::Database;
27
use Koha::Database;
Lines 37-43 $dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('test Link Here
37
")});
38
")});
38
my $biblio_1 = $builder->build_sample_biblio({ title => "heÄllo" });
39
my $biblio_1 = $builder->build_sample_biblio({ title => "heÄllo" });
39
my $biblio_2 = $builder->build_sample_biblio({ title => "hell❤️" });
40
my $biblio_2 = $builder->build_sample_biblio({ title => "hell❤️" });
40
my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { email => 'test@example.org'} });
41
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
41
my $letter = C4::Letters::GetPreparedLetter(
42
my $letter = C4::Letters::GetPreparedLetter(
42
    (
43
    (
43
        module      => 'test',
44
        module      => 'test',
Lines 48-56 my $letter = C4::Letters::GetPreparedLetter( Link Here
48
    )
49
    )
49
);
50
);
50
51
51
C4::Message->enqueue($letter, $patron->unblessed, 'email');
52
53
t::lib::Mocks::mock_preference( 'AutoEmailPrimaryAddress', 'OFF' );
54
C4::Message->enqueue($letter, $patron, 'email');
52
my $message = C4::Message->find_last_message($patron->unblessed, 'TEST_MESSAGE', 'email');
55
my $message = C4::Message->find_last_message($patron->unblessed, 'TEST_MESSAGE', 'email');
53
like( $message->{metadata}, qr{heÄllo} );
56
like( $message->{metadata}, qr{heÄllo} );
57
is ($message->{to_address}, $patron->email, "To address set correctly for AutoEmailPrimaryAddress 'off'");
54
58
55
$letter = C4::Letters::GetPreparedLetter(
59
$letter = C4::Letters::GetPreparedLetter(
56
    (
60
    (
Lines 64-66 $letter = C4::Letters::GetPreparedLetter( Link Here
64
$message->append($letter);
68
$message->append($letter);
65
like( $message->{metadata}, qr{heÄllo} );
69
like( $message->{metadata}, qr{heÄllo} );
66
like( $message->{metadata}, qr{hell❤️} );
70
like( $message->{metadata}, qr{hell❤️} );
67
- 
71
72
t::lib::Mocks::mock_preference( 'AutoEmailPrimaryAddress', 'emailpro' );
73
C4::Message->enqueue($letter, $patron, 'email');
74
$message = C4::Message->find_last_message($patron->unblessed, 'TEST_MESSAGE', 'email');
75
is ($patron->notice_email_address, $patron->emailpro, "To address set correctly for AutoEmailPrimaryAddress 'emailpro'");

Return to bug 18398