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
=> 1;
22 use Koha
::SMTP
::Servers
;
24 use t
::lib
::TestBuilder
;
27 my $schema = Koha
::Database
->new->schema;
28 my $builder = t
::lib
::TestBuilder
->new;
30 subtest
'get_default() tests' => sub {
34 $schema->storage->txn_begin;
36 t
::lib
::Mocks
::mock_config
( 'smtp_server', undef );
38 my $server = Koha
::SMTP
::Servers
->get_default;
39 is
( ref($server), 'Koha::SMTP::Server',
40 'An object of the right type is returned' );
42 ok
( !$server->in_storage,
43 'The default server is correctly retrieved' );
45 my $unblessed_server = $server->unblessed;
46 delete $unblessed_server->{id
};
49 Koha
::SMTP
::Servers
::default_setting
,
50 'The default setting is returned if no user-defined default'
53 t
::lib
::Mocks
::mock_config
(
56 host
=> 'localhost.midway',
59 ssl_mode
=> 'starttls',
60 user_name
=> 'tomasito',
66 my $smtp_config = C4
::Context
->config('smtp_server');
68 $server = Koha
::SMTP
::Servers
->get_default;
69 is
( ref($server), 'Koha::SMTP::Server',
70 'An object of the right type is returned' );
72 $unblessed_server = $server->unblessed;
73 delete $unblessed_server->{id
};
77 'The default setting is overridden by the entry in koha-conf.xml'
80 $schema->storage->txn_rollback;