Bug 22343: Add exec flag on .t files
[koha.git] / t / db_dependent / Koha / SMTP / Servers.t
blobb3506b76b117f72ecc0e6dfd223adf137fd88779
1 #!/usr/bin/perl
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>.
18 use Modern::Perl;
20 use Test::More tests => 1;
22 use Koha::SMTP::Servers;
24 use t::lib::TestBuilder;
25 use t::lib::Mocks;
27 my $schema = Koha::Database->new->schema;
28 my $builder = t::lib::TestBuilder->new;
30 subtest 'get_default() tests' => sub {
32 plan tests => 5;
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};
47 is_deeply(
48 $unblessed_server,
49 Koha::SMTP::Servers::default_setting,
50 'The default setting is returned if no user-defined default'
53 t::lib::Mocks::mock_config(
54 'smtp_server',
56 host => 'localhost.midway',
57 port => 1234,
58 timeout => 121,
59 ssl_mode => 'starttls',
60 user_name => 'tomasito',
61 password => 'none',
62 debug => 1
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};
74 is_deeply(
75 $unblessed_server,
76 $smtp_config,
77 'The default setting is overridden by the entry in koha-conf.xml'
80 $schema->storage->txn_rollback;