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

(-)a/Koha/Library.pm (+17 lines)
Lines 115-120 sub smtp_server { Link Here
115
    return $self;
115
    return $self;
116
}
116
}
117
117
118
=head3 smtp_server_info
119
120
Returns the SMTP server info for the library, or 'system_default' if it is the system default.
121
122
=cut
123
124
sub smtp_server_info {
125
    my ($self) = @_;
126
127
    my $smtp_server = $self->smtp_server;
128
129
    return { name => 'system_default' }
130
        if $smtp_server->is_system_default;
131
132
    return { name => $smtp_server->name, smtp_server_id => $smtp_server->id };
133
}
134
118
=head3 inbound_email_address
135
=head3 inbound_email_address
119
136
120
  my $to_email = Koha::Library->inbound_email_address;
137
  my $to_email = Koha::Library->inbound_email_address;
(-)a/t/db_dependent/Koha/Library.t (-2 / +20 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 1;
22
use Test::More tests => 2;
23
23
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::SMTP::Servers;
25
use Koha::SMTP::Servers;
Lines 93-95 subtest 'smtp_server() tests' => sub { Link Here
93
93
94
    $schema->storage->txn_rollback;
94
    $schema->storage->txn_rollback;
95
};
95
};
96
- 
96
97
subtest 'smtp_server_info() tests' => sub {
98
99
    plan tests => 2;
100
101
    $schema->storage->txn_begin;
102
103
    my $library     = $builder->build_object({ class => 'Koha::Libraries' });
104
    my $smtp_server = $builder->build_object({ class => 'Koha::SMTP::Servers' });
105
106
    # No SMTP server assigned to library, return system default
107
    is_deeply( $library->smtp_server_info, { name => 'system_default' }, 'System default is returned' );
108
109
    # Assign an SMTP server
110
    $library->smtp_server({ smtp_server => $smtp_server });
111
    is_deeply( $library->smtp_server_info, { name => $smtp_server->name, smtp_server_id => $smtp_server->id }, 'The right information is returned when SMTP server is assigned' );
112
113
    $schema->storage->txn_rollback;
114
};

Return to bug 26595