3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Test::More tests => 3;
24 use Koha::SMTP::Servers;
26 use t::lib::TestBuilder;
29 my $schema = Koha::Database->new->schema;
30 my $builder = t::lib::TestBuilder->new;
32 subtest 'transport() tests' => sub {
36 $schema->storage->txn_begin;
38 my $server = $builder->build_object(
40 class => 'Koha::SMTP::Servers',
41 value => { ssl_mode => 'disabled', debug => 0 }
45 my $transport = $server->transport;
47 is( ref($transport), 'Email::Sender::Transport::SMTP', 'Type is correct' );
48 is( $transport->ssl, 0, 'SSL is not set' );
50 $server->set({ ssl_mode => '1' })->store;
51 $transport = $server->transport;
53 is( ref($transport), 'Email::Sender::Transport::SMTP', 'Type is correct' );
54 is( $transport->ssl, '1', 'SSL is set' );
55 is( $transport->debug, '0', 'Debug setting honoured (disabled)' );
57 $server->set({ debug => 1 })->store;
58 $transport = $server->transport;
60 is( $transport->debug, '1', 'Debug setting honoured (enabled)' );
62 $schema->storage->txn_rollback;
65 subtest 'is_system_default() tests' => sub {
69 $schema->storage->txn_begin;
71 my $smtp_server = $builder->build_object({ class => 'Koha::SMTP::Servers' });
72 ok( !$smtp_server->is_system_default, 'A generated server is not the system default' );
74 my $system_default_server = Koha::SMTP::Servers->get_default;
75 ok( $system_default_server->is_system_default, 'The server returned by get_default is the system default' );
77 $schema->storage->txn_rollback;
80 subtest 'to_api() tests' => sub {
84 $schema->storage->txn_begin;
86 my $smtp_server = $builder->build_object({ class => 'Koha::SMTP::Servers' });
87 ok( !exists $smtp_server->to_api->{password}, 'Password is not part of the API representation' );
89 $schema->storage->txn_rollback;