my $dbh = C4::Context->dbh;
# Create two random branches
-my $library_1 = $builder->build({ source => 'Branch' })->{ branchcode };
-my $library_2 = $builder->build({ source => 'Branch' })->{ branchcode };
+my $branch_1 = $builder->build_object({
+ class => 'Koha::Libraries',
+ value => {
+ branchemail => 'branch1@e.mail',
+ branchreplyto => 'branch1@reply.to'
+ }
+});
+my $library_1 = $branch_1->branchcode;
+my $branch_2 = $builder->build_object({
+ class => 'Koha::Libraries',
+ value => {
+ branchemail => 'branch2@e.mail',
+ branchreplyto => 'branch2@reply.to'
+ }
+});
+my $library_2 = $branch_2->branchcode;
my $biblio = $builder->build_sample_biblio({ itemtype => 'DUMMY' });
my $biblionumber = $biblio->id;
};
subtest 'Test automatically canceled expired waiting holds to fill the next hold, with a transfer' => sub {
- plan tests => 5;
+ plan tests => 6;
$dbh->do('DELETE FROM reserves');
$dbh->do('DELETE FROM message_queue');
my @messages = $schema->resultset('MessageQueue')
->search( { letter_code => 'HOLD_CHANGED' } );
- is( @messages, 1, 'Nessage is generated in the message queue when generating transfer' );
+ is( @messages, 1, 'Message is generated in the message queue when generating transfer' );
+
+ my $email = $messages[0];
+ is( $email->from_address, $branch_2->branchemail, "Message is sent from library's email");
};
+
+$schema->storage->txn_rollback;
subtest '_koha_notify_reserve() tests' => sub {
- plan tests => 2;
+ plan tests => 3;
+
+ my $branch = $builder->build_object({
+ class => 'Koha::Libraries',
+ value => {
+ branchemail => 'branch@e.mail',
+ branchreplyto => 'branch@reply.to',
+ pickup_location => 1
+ }
+ });
+ my $item = $builder->build_sample_item({
+ homebranch => $branch->branchcode,
+ holdingbranch => $branch->branchcode
+ });
my $wants_hold_and_email = {
wants_digest => '0',
})->next()->to_address();
is($sms_message_address, undef ,"We should not populate the sms message with the sms number, sending will do so");
- my $email_message_address = $schema->resultset('MessageQueue')->search({
+ my $email = $schema->resultset('MessageQueue')->search({
letter_code => 'HOLD',
message_transport_type => 'email',
borrowernumber => $hold_borrower,
- })->next()->to_address();
- is($email_message_address, undef ,"We should not populate the hold message with the email address, sending will do so");
+ })->next();
+ my $email_to_address = $email->to_address();
+ is($email_to_address, undef ,"We should not populate the hold message with the email address, sending will do so");
+ my $email_from_address = $email->from_address();
+ is($email_from_address,'branch@e.mail',"Library's from address is used for sending");
};